magmax / python-readchar

Python library to read characters and key strokes
MIT License
143 stars 45 forks source link

Proposed fix to issue #5 #6

Closed mbdevpl closed 6 years ago

mbdevpl commented 9 years ago

This request is my proposed fix to #5 that I had. This fix leads to some code duplication, but that's just one line. Fix was tested on Windows 7 Pro x64, Python 3.4.

However, the change in README.rst made in commit 20feb478f8a4926863d89581e99c03ab20c3d703 seems to be breaking the linux build:

python-readchar$ python3 setup.py build
Traceback (most recent call last):
  File "setup.py", line 39, in <module>
    long_description=read_description(),
  File "setup.py", line 11, in read_description
    return fd.read()
  File "/usr/lib/python3.4/codecs.py", line 313, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 2467: invalid start byte

On the other hand without this change I cannot build the project on Windows (as mentioned in #5). To sum up, further work is needed.

GabrielSalla commented 7 years ago

You can just change the read_description() function to open the file with UTF-8 encoding.

def read_description():
    with open('README.rst', encoding='utf-8') as fd:
        return fd.read()