Fix reading from a closed stdin buffer #36
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary: Couple of
flake8
plugins rely on pycodestyle.stdin_get_value, which does not cache the string, after reading it from stdin and closing the buffer. This means that if there are two plugins using this function - the second plugin relying on this function, cannot read from stdin, because it was closed, andValueError: I/O operation on closed file
gets raised.Fix: use flake8.utils.stdin_get_value, which caches the stdin, so that multiple plugins can use it. It is based on flake8-commas that does not seem to have this issue.
Steps to reproduce:
requirements.txt
:Run:
Expected output: lint successfully.
Actual output:
Additional comments:
In my environment this error got triggered in
flake8-print
andflake8-tuple
. I am simultaneously doing a similar fix toflake8-tuple
as well. However, there must be a third plugin that usespycodestyle.stdin_get_value
first time. I will investigate and do a similar fix as well.I bumped version up as it would be great to release this fix quickly - it would save my eyes from emacs+flycheck blowing up with an error taking half the buffer on every file save. :)
Let me know if I can improve this to expedite the release.
Thank you.