stefankoegl/python-json-pointer

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

kepstin opened this issue · 3 comments

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).

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.

Everything is working as expected with your patch, thanks.

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