SublimePythonTidy icon indicating copy to clipboard operation
SublimePythonTidy copied to clipboard

Fix encoding issues with StringIO

Open mdornseif opened this issue 12 years ago • 2 comments

The current code took the (unicode) view and stuffed it into a StringIO byte stream. The resulting encoding being seen 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.

https://github.com/witsch/SublimePythonTidy/issues/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 witsch/SublimePythonTidy#1

PythonTidy also has a bunch of (not fixed so far) unicode issues, e.g. see mdornseif/PythonTidy#1

mdornseif avatar May 28 '12 05:05 mdornseif

cool,it works

softside avatar Aug 22 '12 02:08 softside

i've just merged https://github.com/witsch/SublimePythonTidy/pull/7, which seems to address the same problem. it's slightly newer, so i should have looked at your pull request first. sorry about that!

the patches looks pretty much equal. is there anything missing from your POV, or can this be closed? i'm also happy to merge if you update your pull request again. that way the !# would go in as well...

ps: and sorry for taking so long!

witsch avatar Mar 12 '13 08:03 witsch