-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Don't use stdlib private API in animation.py. #12368
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
Don't use stdlib private API in animation.py. #12368
Conversation
37dcbe1
to
61a0e41
Compare
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.
Overall, I think this makes sense. Just a couple small notes.
lib/matplotlib/animation.py
Outdated
out = TextIOWrapper(BytesIO(out)).read() | ||
err = TextIOWrapper(BytesIO(err)).read() | ||
_log.debug("MovieWriter: stdout: %s", out) | ||
_log.debug("MovieWriter: stderr: %s", err) |
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.
Can you put back the newlines? It helps when reading multi-line output.
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.
sure, this was just copied from the other block. fixed.
return '', '' | ||
|
||
self._proc = ProcessStandin() | ||
|
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.
Is removing this safe? self._run()
is still called, I guess it is deferring to a baseclass implementation?
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.
The parent class (FileMovieWriter) invokes _run in finish:
def finish(self):
# Call run here now that all frame grabbing is done. All temp files
# are available to be assembled.
self._run()
MovieWriter.finish(self) # Will call clean-up
so if we override finish(), we don't call _run() at all.
(TBH I think the inheritance chain of methods could be refactored a bit but that's not the point of this PR.)
Also note that there is actually test coverage for this :)
The _std{out,err}_buff attributes on Popen objects don't exist anymore on Unices (since CPython 3.4). As these buffers are not accessible anymore in finish(), move the status check and possible exception throwing to cleanup(), where they are still available. Don't silently drop exceptions; this shows that ProcessStandin previously used by HTMLWriter was also buggy (communicate() needed to return bytes, not str); instead of using it, just do all the work in finish(), similarly to PillowWriter).
61a0e41
to
02e5358
Compare
The _std{out,err}_buff attributes on Popen objects don't exist anymore
on Unices (since CPython 3.4). As these buffers are not accessible
anymore in finish(), move the status check and possible exception
throwing to cleanup(), where they are still available.
Don't silently drop exceptions; this shows that ProcessStandin
previously used by HTMLWriter was also buggy (communicate() needed to
return bytes, not str); instead of using it, just do all the work in
finish(), similarly to PillowWriter).
Closes the first part of #9205 (but not #9205 (comment)).
PR Summary
PR Checklist