Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix ImportError: No module named 'StringIO' on Python 3 #5788
Conversation
cgohlke
added some commits
Jan 3, 2016
tacaswell
added the
needs_review
label
Jan 3, 2016
|
Thanks, I don't think it matters much but I would prefer the svg examples to use |
|
On the other hand, it buffer is being used to stand in for an open file handle which should be bytes? |
tacaswell
added this to the
Critical bugfix release (1.5.1)
milestone
Jan 3, 2016
|
The file is opened in |
|
The SVG backend will wrap any file-like objects opened in binary mode with a UTF-8 text encoder, so it's not actually necessary to pick one over the other based on the strict difference between |
Just wanted to add a "ditto" here. One of the reasons it's designed this way is so that users can pass the same bytes-writing file object to any of the backends and have it work (since many of the output formats are binary). The inverse wouldn't be true, i.e. one couldn't write PNG to a text-writing file object. |
|
Yes it's all bikeshedding and the only question is if one thing is more clear than another in the SVG examples? |
|
I have changed them over to Also, those interactive demos are super cool! |
tacaswell
merged commit 6461fd9
into matplotlib:master
Jan 7, 2016
tacaswell
added a commit
that referenced
this pull request
Jan 7, 2016
|
|
tacaswell |
cf38ed7
|
tacaswell
removed the
needs_review
label
Jan 7, 2016
tacaswell
added a commit
that referenced
this pull request
Jan 7, 2016
|
|
tacaswell |
9fe5abe
|
cgohlke commentedJan 3, 2016
Several examples use the
StringIOmodule, which fails to import on Python 3.This PR uses
io.BytesIOinstead. Tested with Python 2.7 and 3.5 on Windows.Please review. Not sure if it would be better to use
io.StringIOorsix.StringIOinstead.