mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-31 03:06:53 +00:00
Update stdin_get_value monkey-patching
Let's use an enclosed function to replace the stdin_get_value function on pep8. Closes #107
This commit is contained in:
parent
d5e3987a9c
commit
5021da880c
2 changed files with 22 additions and 9 deletions
|
|
@ -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
|
||||
------------------
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue