-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
UnicodeDecodeError on importing pyplot in python2 #11955
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
Milestone
Comments
Suggested in comment change:
seems to fix the problem. In python2 crash doesn't happen anymore and the code looks to work with python 3.6 either. |
tacaswell
added a commit
to tacaswell/matplotlib
that referenced
this issue
Aug 28, 2018
6 tasks
tacaswell
added a commit
to tacaswell/matplotlib
that referenced
this issue
Aug 28, 2018
The issue is that the lines coming out of `traceback.format_stack()` are bytes (aka python2 str). This file uses `unicode_literals` so the string literals are unicode. If any of the paths in the stack have non-ascii we get UnicodeDecode exceptions when trying to convert the byte strings to unicode with ascii. The `str` calls will have no effect on python3 and down-cast the unicode to bytes so the operations will work. A better fix would be to sort out what encoding the bytes from `format_stack` are in and convert them to unicode, but this is simpler and is unlikely to make things worse than they were. closes matplotlib#11955
all good like originally suggested changed. |
tacaswell
added a commit
to tacaswell/matplotlib
that referenced
this issue
Aug 28, 2018
The issue is that the lines coming out of `traceback.format_stack()` are bytes (aka python2 str). This file uses `unicode_literals` so the string literals are unicode. If any of the paths in the stack have non-ascii we get UnicodeDecode exceptions when trying to convert the byte strings to unicode with ascii. The `str` calls will have no effect on python3 and down-cast the unicode to bytes so the operations will work. A better fix would be to sort out what encoding the bytes from `format_stack` are in and convert them to unicode, but this is simpler and is unlikely to make things worse than they were. closes matplotlib#11955
@tacaswell looks like merging #11957 didn't automatically close this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug summary
UnicodeDecodeError on importing pyplot If some module in call stack is located in directory with non-ascii character in path. The problem is that traceback.format_stack() returns list of 'str' objects in python2. This problem happens only on python2.
Code for reproduction
Create two modules in a directory with a non-ascii character in the path.
Run first module.
Actual outcome
Following traceback happens
Matplotlib version
print(matplotlib.get_backend())
): 'WX"The text was updated successfully, but these errors were encountered: