Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix several SVG closing issues #7330

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

Merged
dopplershift merged 4 commits into matplotlib:v2.x from QuLogic:fix-svg-close
Oct 27, 2016
Merged

Conversation

Copy link
Member

@QuLogic QuLogic commented Oct 22, 2016

Fix a leak where the wrong file handle was closed (maybe related to warnings in #6870? @Kojoley). Fix premature closing of underlying files, and some pickling issues.

@QuLogic QuLogic added this to the 2.0 (style change major release) milestone Oct 22, 2016
@@ -1230,8 +1234,10 @@ def _print_svg(self, filename, svgwriter, fh_to_close=None, **kwargs):
self.figure.draw(renderer)
renderer.finalize()
finally:
if detach:
svgwriter.detach()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope this works on Python 2...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess I'll be needing a Python 2 version.

svgwriter.detach()
else:
svgwriter.reset()
svgwriter.stream = io.BytesIO()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are doing it not in a right way. Just RendererSVG.writer should be deleted in RendererSVG.finalize.

Closes #6870

Copy link
Member

@tacaswell tacaswell Oct 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to finalize should go it in the finally block then.

Copy link
Member Author

@QuLogic QuLogic Oct 24, 2016
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not intended to fix #6870. It is the Python 2 equivalent of 946367f, which fixes #6926.

#6870 is fixed by 7fe52ac, because the entire cached renderer (not just this part) is not supposed to be pickled.

Copy link
Member

I do not fully understand the difference between detach and fh_to_close.

There may need to be a bigger change in that renderers are allowed to report that they can not be cached (as I suspect that calling draw_artist with the svg renderer would not work).

Copy link
Member

Kojoley commented Oct 24, 2016

I previously refactored print_svg and print_svgz with context manager, but have not opened a PR with the changes. Would you like me to open a PR?

Copy link
Member Author

QuLogic commented Oct 24, 2016

Sure, open directly to this branch and we'll include it in this PR.

Copy link
Member

Kojoley commented Oct 24, 2016

It does not clearly cherry-picks here due to added detach magic.

Copy link
Member Author

QuLogic commented Oct 24, 2016

Post a branch to your fork and I'll see; maybe I can drop the detach stuff...

Copy link
Member

Kojoley commented Oct 24, 2016

QuLogic and others added 3 commits October 24, 2016 20:42
It doesn't seem like it needs to cache the renderer itself, since other
artists get it from the figure in the same way.
It's not allowed to be pickled on a Figure, so presumably it shouldn't
be allowed on the Axes either.
Fixes matplotlib#6870.
Fixes matplotlib#6181.
Fixes matplotlib#3899.
This leaves the owned-by-caller file object alone instead of forcing it
to close as well.
Fixes matplotlib#6926, though I'm not entirely sure why only the cleanup decorator
+ usetex triggers it.
Copy link
Member Author

QuLogic commented Oct 25, 2016

Thanks; I've incorporated it into this PR and we can drop the confusing fh_to_close stuff. However, the detach stuff is still necessary to fix #6926.

Copy link
Member Author

QuLogic commented Oct 26, 2016

Restarted the failed build, so it's good from my side.

@QuLogic QuLogic changed the title (削除) Fix several SVG closing issues (削除ここまで) (追記) [MRG] Fix several SVG closing issues (追記ここまで) Oct 26, 2016
Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look good to me now.

@dopplershift dopplershift merged commit 92da7f6 into matplotlib:v2.x Oct 27, 2016
@dopplershift dopplershift changed the title (削除) [MRG] Fix several SVG closing issues (削除ここまで) (追記) Fix several SVG closing issues (追記ここまで) Oct 27, 2016
Copy link
Contributor

So I'm a little rusty--do I need to backport this to master?

@QuLogic will you make sure all the issues fixed by this get closed?

Copy link
Member

@dopplershift no, we every-so-often merge v2.x into master.

I think @QuLogic and I are currently playing chicken about who will do it next 😉 .

Copy link
Member Author

QuLogic commented Oct 28, 2016

The issues will close automatically when the commits get into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@tacaswell tacaswell tacaswell left review comments

@dopplershift dopplershift dopplershift approved these changes

@Kojoley Kojoley Kojoley approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v2.0.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /