Skip to content

Use ASCII hyphen in README.rst to prevent setup.py from raising UnicodeDecodeError when reading that file to set long_description #16703

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

Closed

Conversation

terrycojones
Copy link

When installing matplotlib under pypy (nightly build, downloaded an hour ago):

$ pypy
Python 3.7.4 (cadeed6ce576, Mar 01 2020, 14:23:41)
[PyPy 7.3.1-alpha0 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]

I get the following exception:

$ pip install matplotlib
Collecting matplotlib
  Using cached matplotlib-3.2.0.tar.gz (40.5 MB)
    ERROR: Command errored out with exit status 1:
     command: /home/terry/.virtualenvs/pypy/bin/pypy3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-q6fmzymu/matplotlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-q6fmzymu/matplotlib/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-install-q6fmzymu/matplotlib/pip-egg-info
         cwd: /tmp/pip-install-q6fmzymu/matplotlib/
    Complete output (21 lines):
    
    Edit setup.cfg to change the build options; suppress output with --quiet.
    
    BUILDING MATPLOTLIB
      matplotlib: yes [3.2.0]
          python: yes [3.7.4 (cadeed6ce576, Mar 01 2020, 14:23:41) [PyPy
                      7.3.1-alpha0 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]]
        platform: yes [linux]
     sample_data: yes [installing]
           tests: no  [skipping due to configuration]
             agg: yes [installing]
           tkagg: yes [installing; run-time loading from Python Tcl/Tk]
          macosx: no  [Mac OS-X only]
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-q6fmzymu/matplotlib/setup.py", line 229, in <module>
        long_description = fd.read()
      File "/home/terry/.virtualenvs/pypy/lib-python/3/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2619: 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.

which you can also see here:

$ python
Python 3.7.4 (cadeed6ce576, Mar 01 2020, 14:23:41)
[PyPy 7.3.1-alpha0 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``it's nonsense all the way down,
and also all the way up''
>>>> f = open('README.rst')
>>>> d = f.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/terry/.virtualenvs/pypy/lib-python/3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 3082: ordinal not in range(128)

Looking in README.rst at offset 3082 I found a non-ASCII hyphen (and a second one a couple of lines later). Changing them to regular hyphens (as in this pr) fixes the error.

…sing UnicodeDecodeError when reading that file to set long_description.
@tacaswell
Copy link
Member

The other option is to explicitly set the encoding in the fd.read() call?

@tacaswell tacaswell added this to the v3.2.1 milestone Mar 7, 2020
@QuLogic
Copy link
Member

QuLogic commented Mar 7, 2020

See notes in #16670 and other PR #16671.

@terrycojones
Copy link
Author

Suggest closing this as the approach in #16671 is a better one, IMO.

@timhoffm
Copy link
Member

timhoffm commented Mar 7, 2020

Closed in favor of #16671 .

@timhoffm timhoffm closed this Mar 7, 2020
@QuLogic QuLogic removed this from the v3.2.1 milestone Mar 18, 2020
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