Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly decode appdirs.py as UTF-8 #152

Merged
merged 1 commit into from
Jan 28, 2021

Conversation

neirbowj
Copy link
Contributor

When setup.py reads appdirs.py without an encoding defined, it can sometimes fail having guessed the wrong encoding. For example:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc8 in position 129: ordinal not in range(128)

Whereas the builtin open does not accept the encoding argument until 3.0, io.open supports encoding under all versions supported by appdirs.

@nchepanov
Copy link

I'm seeing this problem too.

@asottile
Copy link

here is a reproduction with python3.6 on linux:

$ LANG=C python3 -m pip wheel .
Processing /tmp/appdirs
    ERROR: Command errored out with exit status 1:
     command: /tmp/appdirs/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-aidjyogf/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-aidjyogf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-iozfgf3t
         cwd: /tmp/pip-req-build-aidjyogf/
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-aidjyogf/setup.py", line 19, in <module>
        for line in read("appdirs.py").splitlines():
      File "/tmp/pip-req-build-aidjyogf/setup.py", line 13, in read
        out = "\n" + inf.read().replace("\r\n", "\n")
      File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc8 in position 107: ordinal not in range(128)
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 20.2.1; however, version 20.2.3 is available.
You should consider upgrading via the '/tmp/appdirs/venv/bin/python3 -m pip install --upgrade pip' command.

Copy link

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nchepanov
Copy link

The 1.4.4 version of the package is still unusable in Python 3.

Copy link

@nchepanov nchepanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@zoofood zoofood merged commit 8eacfa3 into ActiveState:master Jan 28, 2021
@zoofood
Copy link
Contributor

zoofood commented Jan 28, 2021

Thanks for the submission. Cheers.

severinstrobl added a commit to severinstrobl/spack that referenced this pull request Jan 5, 2022
Reading appdirs.py without explicitly requesting UTF-8 decoding results
in the build process to fail for Python 3.6.

See ActiveState/appdirs#152 for the upstream
fix.
adamjstewart pushed a commit to spack/spack that referenced this pull request Jan 5, 2022
Reading appdirs.py without explicitly requesting UTF-8 decoding results
in the build process to fail for Python 3.6.

See ActiveState/appdirs#152 for the upstream
fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants