sqlalchemyorg / zimports

Python import rewriter
MIT License
75 stars 6 forks source link

resolves #14 #15

Closed RamonWill closed 4 years ago

RamonWill commented 4 years ago

On Windows OS, If a file contains unicode string(s), zimports would open that file using the systems locale encoder, for windows this is CP-1252, this will raise a UnicodeDecodeError.

This proposed resolution will set the file encoding to utf-8 which allows the file containing unicode strings to be read in by zimports.

zzzeek commented 4 years ago

OK. I'm going to use this PR, but I have to apologize, when you posted this issue it seemed really familiar to me but I couldn't find why. when i went to my local copy apparnetly I was working on this to some degree with the code snippet I have at #8. so.... let me merge this first then try to get that one in as well.

zzzeek commented 4 years ago

OK so this is merged. thanks! However I subsequently merged another change that will use importlib.util.decode_source to read the file. if you can make sure that still works for you I can put out 0.2.1.

RamonWill commented 4 years ago

No worries, perfect it still works with your changes. thanks again, Ramon

zzzeek commented 4 years ago

OK I put it up, though hopefully people just use the github link for this tool.