Fix ImportError: No module named 'StringIO' on Python 3#5788
Fix ImportError: No module named 'StringIO' on Python 3#5788tacaswell merged 4 commits intomatplotlib:masterfrom cgohlke:patch-1
Conversation
|
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? |
|
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! |
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.