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
Fix ImportError: No module named 'StringIO' on Python 3 #5788
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
StringIO
module, which fails to import on Python 3.This PR uses
io.BytesIO
instead. Tested with Python 2.7 and 3.5 on Windows.Please review. Not sure if it would be better to use
io.StringIO
orsix.StringIO
instead.