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

Python 3.6+ Support #35

Open
thomasjfox1 opened this issue Feb 14, 2018 · 2 comments
Open

Python 3.6+ Support #35

thomasjfox1 opened this issue Feb 14, 2018 · 2 comments

Comments

@thomasjfox1
Copy link

This is an improvement rather than an issue at the moment, but is there any plan for Python 3.6+ support?

Per the README, the optional install of python3 and the Python 3.+ in the project requirements threw me off a bit. When running with 3.6.4, the tests throw a number of issues, starting with the utf8 decoding. I rolled back to the macOS default of 2.7.14 and was able to run the tests/server successfully.

(This could very well also be unrelated to this project's Python 3.6+ support and some weird python3 macOS nonsense.)

@thomasjfox1
Copy link
Author

thomasjfox1 commented Feb 15, 2018

For added detail (using the caniusepython3 pip package):

❯ caniusepython3 -r requirements.txt
Finding and checking dependencies ...

You need 1 project to transition to Python 3.
Of that 1 project, 1 has no direct dependencies blocking its transition:

 flask-bcrypt

Per the flask-bcrypt docs:
"In Python 3, you need to use decode(‘utf-8’) on generate_password_hash(), like below:

pw_hash = bcrypt.generate_password_hash(‘hunter2’).decode(‘utf-8’)

This all appears to be done correctly in the repo then, so I'm guessing that it's macOS related at this point.

@dimitriwalters
Copy link

The flask docs are wrong, in Python 3 strings are decoded for you and you'll get an error if you try:

Traceback (most recent call last):
  ...
  File "/home/application/models.py", line 12, in __init__
    self.password = User.hashed_password(password)
  File "/home/application/models.py", line 16, in hashed_password
    return bcrypt.generate_password_hash(password).decode("utf-8")
AttributeError: 'str' object has no attribute 'decode'

Simply removing the decode function will make the app run fine, and pass all the tests too.

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

No branches or pull requests

2 participants