Skip to content

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

@kepstin

Description

@kepstin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions