-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that stderr/stdout has flush attr before calling it #1248
Conversation
@casperdcl Anything I can do to help move this along? |
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.03%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
This also happens with gitbash on Windows, see iterative/dvc#7465 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think the PR description is wrong.
This PR does not fix sys.std{err,out} == None
(sys.std{err,out}.write()
would fail if it was really None
).
I think this PR fixes libraries which monkey-patch sys.std{err,out}
removing their flush()
method.
thanks! Sorry for the long delay 🙏 |
/tag v4.63.1 165a23a |
The recent commit 63f427b (which was evidently in response to #1177) is leading to errors in some cases. It turns out that
sys.stdout
andsys.stderr
can beNone
in some cases, as mentioned in the note at the bottom of this section in the python docs. (This is news to me, and the cases I've encountered this in are not like what the docs suggest.) When they areNone
an error occurs insidetqdm
because obviouslyNone.flush()
does not exist.This PR just checks that
stderr
andstdout
actually have aflush
attribute before using that attribute. Note that we can't just reusefp_flush
because the point of #1177 was that bothstdout
andstderr
need to be flushed.For reference, I've encountered the bug on two systems: