WebAgg favicon serving error in Python 3 #2265
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
backend_webagg.py, near line 381:
Doing self.write(fd.read()) is an error: Tornado converts everything passed into write() to utf-8 at least in Python 3, so that I get the following runtime error after opening a web browser:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/tornado/web.py", line 1042, in _execute
getattr(self, self.request.method.lower())(_args, *_kwargs)
File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_webagg.py", line 381, in get
self.write(fd.read())
File "/usr/lib/python3.3/codecs.py", line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
This error is reasonable: trying to convert binary data - matplotlib.png - to utf8 is definitely a bad idea. I am not sure how to fix it, as I am novice to Tornado and Python in general.