diff --git a/CHANGES.rst b/CHANGES.rst index 1762334..8cf0abd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,13 +1,19 @@ CHANGES ======= -2.x.y - 2015-aa-bb +2.5.1 - 2015-12-15 ------------------ - **Bug** Properly look for ``.flake8`` in current working directory (`GitLab#103`_) +- **Bug** Monkey-patch ``pep8.stdin_get_value`` to cache the actual value in + stdin. This helps plugins relying on the function when run with + multiprocessing. (`GitLab#105`_, `GitLab#107`_) + .. _GitLab#103: https://gitlab.com/pycqa/flake8/issues/103 +.. _GitLab#105: https://gitlab.com/pycqa/flake8/issues/105 +.. _GitLab#107: https://gitlab.com/pycqa/flake8/issues/107 2.5.0 - 2015-10-26 ------------------ diff --git a/flake8/engine.py b/flake8/engine.py index e90940e..d929f83 100644 --- a/flake8/engine.py +++ b/flake8/engine.py @@ -297,13 +297,20 @@ def get_python_version(): return '%s%s on %s' % (impl, platform.python_version(), platform.system()) -def make_stdin_get_value(): - value = pep8.stdin_get_value() - if sys.version_info < (3, 0): - stdin = io.BytesIO(value) - else: - stdin = io.StringIO(value) - return stdin.getvalue +def make_stdin_get_value(original): + def stdin_get_value(): + if not hasattr(stdin_get_value, 'cached_stdin'): + value = original() + if sys.version_info < (3, 0): + stdin = io.BytesIO(value) + else: + stdin = io.StringIO(value) + stdin_get_value.cached_stdin = stdin + else: + stdin = stdin_get_value.cached_stdin + return stdin.getvalue() + + return stdin_get_value -pep8.stdin_get_value = make_stdin_get_value() +pep8.stdin_get_value = make_stdin_get_value(pep8.stdin_get_value)