ZeevG/python-forecast.io

Handling non-ASCII characters in README.rst on Python 3

Closed this issue · 1 comments

I'm a paying customer at forecast.io and I'm running into a strange issue with python-forecast.io, but am struggling to re-produce it under my own conditions.

When I build docs for my project on readthedocs.org using a Python 3 runtime, I get the following error:

Downloading/unpacking python-forecastio==1.3.1 (from -r requirements.txt (line 11))
  Downloading python-forecastio-1.3.1.tar.gz
  Running setup.py (path:/var/build/user_builds/codefurther/envs/master/build/python-forecastio/setup.py) egg_info for package python-forecastio
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/var/build/user_builds/codefurther/envs/master/build/python-forecastio/setup.py", line 28, in <module>
        long_description=open('README.rst').read(),
      File "/home/docs/checkouts/readthedocs.org/user_builds/codefurther/envs/master/lib/python3.4/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 425: ordinal not in range(128)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/var/build/user_builds/codefurther/envs/master/build/python-forecastio/setup.py", line 28, in <module>

    long_description=open('README.rst').read(),

  File "/home/docs/checkouts/readthedocs.org/user_builds/codefurther/envs/master/lib/python3.4/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 425: ordinal not in range(128)

However, if I use Python 2, I do not see the error. A colleague who is helping me to test my package on Mac also gets the same error on Python 3.4.2. However, I can't reproduce the problem on either Windows under 3.4.1 or Ubuntu on 3.4.0.

I've looked at the README.rst file and sure enough the apostrophe in the following text

...what its doing (it’s very simple).

appears to be somewhat exotic as my test code shows...

w
h
a
t

i
t
s

d
o
i
n
g

(
i
t
Non-ASCII char found! at pos 425 ( 0x1a9 ) character is â
Non-ASCII char found! at pos 426 ( 0x1aa ) character is €
Non-ASCII char found! at pos 427 ( 0x1ab ) character is ™
s 

I've forked python-forecastio and made a change to setup.py so that it handles and decodes non-ascii characters. See 52b7f4c. I tried to use the read() function that was present, but not actually used.

With this change made, and by using my forked repository on GitHub in my own project's setup.py, my docs on readthedocs.org now build correctly.

Can you please advise if you think there is an issue, and if so I guess you could either remove the non-ascii chars in README.rst, or I'd happily offer a pull request.

Great module

ZeevG commented

Thanks for the heads up. This should be resolved in 5126549.

If you continue to run into this problem, reopen the issue.