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

Fix UnicodeDecodeError in setup.py. #171

Merged
merged 4 commits into from Nov 7, 2018

Conversation

sebastic
Copy link
Contributor

@sebastic sebastic commented Nov 5, 2018

As mentioned in #169, setup.py fails to read the README.md due to an UnicodeDecodeError.

This is fixed by explicitly setting the encoding, and using the codecs library with Python 2.7.

@megies
Copy link
Contributor

megies commented Nov 5, 2018

Although I couldn't reproduce the problem, I agree that explicit decoding is definitively the right thing to do here.

Personally, I'd avoid the Python 3 if/else, though and just explicitly decode:

with open('README.md', 'rb') as fh:
    data = fh.read()
data = data.decode('utf-8')

@sebastic
Copy link
Contributor Author

sebastic commented Nov 5, 2018

Using decode works too, but since the with statement was added in Python 2.5 the interpreter version requirements should probably be documented in setup.py too.

@megies
Copy link
Contributor

megies commented Nov 5, 2018

I agree, Python versions (2.7 and 3.x) should be specified in setup.py.

@sebastic
Copy link
Contributor Author

sebastic commented Nov 5, 2018

python_requires has been added to setup.py, see:

https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires

setup.py Outdated Show resolved Hide resolved
setup.py Show resolved Hide resolved
Copy link
Contributor

@megies megies left a comment

Choose a reason for hiding this comment

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

Good to merge, I'd say @karimbahgat

@karimbahgat
Copy link
Collaborator

Looks good, thanks for the swift fix!

@sebastic sebastic deleted the setup branch November 7, 2018 05:51
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.

None yet

3 participants