Movatterモバイル変換


[0]ホーム

URL:


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

Matplotlib savefig() closes BytesIO object when saving in postscript format#1862

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mdboom merged 1 commit intomatplotlib:masterfrommdboom:ps-file-closing
Mar 27, 2013

Conversation

mdboom
Copy link
Member

In Python 3, I am seeing the following bug:

In [1]: from io import BytesIOIn [2]: import matplotlib.pyplot as pltIn [3]: b = BytesIO()In [4]: fig = plt.figure()In [5]: ax = fig.add_subplot(1,1,1)In [6]: ax.plot([1,2,3])Out[6]: [<matplotlib.lines.Line2D at 0x104a90990>]In [7]: fig.savefig(b, format='eps')In [8]: b.seek(0)---------------------------------------------------------------------------ValueError                                Traceback (most recent call last)<ipython-input-8-22abda41fe70> in <module>()----> 1 b.seek(0)ValueError: I/O operation on closed file.

As far as I can tell, this does not occur withStringIO in Python 2.x.

@mdboom - is this related to#1779?

@mdboom
Copy link
Member

Nope -- this bug is only on master, and perhaps related to#1826.

…handles passed to it on Python 3. The TextIOWrapper that handles the encoding from unicode to ascii needs to be detached before its destructor is called, otherwise it will call close on the underlying file object. Also cleans up how with statements are handled to avoid the sometimes problematic null contextmanager.
@astrofrog
Copy link
ContributorAuthor

@mdboom - this works for me - thanks!

mdboom added a commit that referenced this pull requestMar 27, 2013
Matplotlib savefig() closes BytesIO object when saving in postscript format
@mdboommdboom merged commitca476df intomatplotlib:masterMar 27, 2013
HubertHolin pushed a commit to HubertHolin/matplotlib that referenced this pull requestApr 7, 2013
…handles passed to it on Python 3. The TextIOWrapper that handles the encoding from unicode to ascii needs to be detached before its destructor is called, otherwise it will call close on the underlying file object. Also cleans up how with statements are handled to avoid the sometimes problematic null contextmanager.
pelson pushed a commit to pelson/matplotlib that referenced this pull requestApr 29, 2013
…handles passed to it on Python 3. The TextIOWrapper that handles the encoding from unicode to ascii needs to be detached before its destructor is called, otherwise it will call close on the underlying file object. Also cleans up how with statements are handled to avoid the sometimes problematic null contextmanager.
@mdboommdboom deleted the ps-file-closing branchAugust 7, 2014 13:50
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@mdboom@astrofrog

[8]ページ先頭

©2009-2025 Movatter.jp