stefankoegl / python-json-pointer

Resolve JSON Pointers in Python
https://python-json-pointer.readthedocs.org/
Other
141 stars 43 forks source link

setup.py ascii decode error in python3 when using "C" system locale. #8

Closed kepstin closed 10 years ago

kepstin commented 10 years ago

Hi, I'm seeing the following error:

$ LC_ALL=C python3.4 -B setup.py config
Traceback (most recent call last):
  File "setup.py", line 9, in <module>
    src = open(filename).read()
  File "/usr/lib64/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 179: ordinal not in range(128)

This is causing issues during linux distribution software packaging, where you often can't rely on having a unicode locale set.

The issue appears to be that in the 'C' locale, python is defaulting to ASCII decoding rather than UTF-8. You should explicitly state the encoding of the file being opened to solve this issue; the syntax io.open(filename, encoding="utf-8") should work in python2.6 and newer (including python3).

stefankoegl commented 10 years ago

Thanks for reporting this! It should be fixed now.

Please let me know if it works for you. If so, I'll prepare a new release with the fix.

kepstin commented 10 years ago

Everything is working as expected with your patch, thanks.

stefankoegl commented 10 years ago

jsonpointer 1.4 has just been released with this fix. Thanks!