React-Redux-Flask icon indicating copy to clipboard operation
React-Redux-Flask copied to clipboard

Python 3.6+ Support

Open thomasjfox1 opened this issue 7 years ago • 2 comments

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 avatar Feb 14 '18 05:02 thomasjfox1

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.

thomasjfox1 avatar Feb 15 '18 01:02 thomasjfox1

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.

dimitriwalters avatar Mar 05 '18 19:03 dimitriwalters