Showing results for 
Search instead for 
Did you mean: 

Python Course test three Attribute Error

Node Link

I haven't seen anyone else posting with this issue, so its probably something I did on accident that broke the test.

Nonetheless, just in case someone else runs into this issue, I am posting about it here. I have also provided feedback in the course itself with the same thing.

The issue:
Test 03 of the Python Course gives FAILED tests/ - AttributeError: 'str' object has no attribute 'decode'

The cause:
In, the return statement in the _generate_token function has ".decode('ascii')" at the end.

I fixed this by removing that part of the return statement, as it seems to me that the next function down already decodes the token (being literally named decode_token), however I do not know if this will break anything further down the line.

I would like to know if this is intentionally part of the return statement, and if its supposed to give  the  attribute error. Thank you.



I encountered the same error.


I encountered the same issue, and also have issues with 'register' and 'sign in' when running the app in my browser.

Changed to JWT_SECRET_KEY in ./routes/

def register():
    dao = AuthDAO(current_app.driver, current_app.config.get("JWT_SECRET_KEY"))

def login():
    dao = AuthDAO(current_app.driver, current_app.config.get("JWT_SECRET_KEY"))

Modified _generate_token function with a try except block


def _generate_token(self, payload)
    encoded = jwt.encode(payload, self.jwt_secret, algorithm="HS256")
        return encoded.decode("ascii")
    except AttributeError:
        return encoded