Fix encoding issues with StringIO #5
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.
The current code took the (unicode) view and stuffed
it into a
StringIO
byte stream. The resulting encoding beingseen by PythonTidy was dependent on the configuration of the
system the code was running on and on implementation
details in StringIO.
It than read the result (a bytestream) and wrote it into
the (unicode) view. Again with indeterminable results
based on the default encodings of the host system.
For me opening the file http://filez.foxel.org/211a0I1L3t3n2I3P1L25
and pressing CTRL-ALT-CMD-T worked once but pressing it twice
resulted in an
UnicodeException
.#1 shows
the same issue and https://github.com/do3cc/SublimePythonTidy/commit/efc88be
seems to be an attempt to fix it.
This changeset ensures that
a) views are treated as unicode
b) StringIOs are treated as byte stream
This fixes #1
PythonTidy also has a bunch of (not fixed so far) unicode issues,
e.g. see mdornseif/PythonTidy#1