TypeError: 'unicode' does not have the buffer interface after updating to Python 2.7.7
wiesson opened this issue · 4 comments
wiesson commented
I've installed 2.7.7 with brew and reconstructed my virtualenv, based on the 2.7.7 package.
Flask responses with this error:
Traceback (most recent call last):
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/arnewiese/Dev/projects/flaskproj/app/auth/views.py", line 39, in login
if user is not None and user.verify_password(form.password.data):
File "/Users/arnewiese/Dev/projects/flaskproj/app/users/models.py", line 149, in verify_password
return check_password_hash(self.password_hash, password)
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/werkzeug/security.py", line 224, in check_password_hash
return safe_str_cmp(_hash_internal(method, salt, password)[0], hashval)
File "/Users/arnewiese/Dev/projects/flaskproj/venv/lib/python2.7/site-packages/werkzeug/security.py", line 117, in safe_str_cmp
return _builtin_safe_str_cmp(a, b)
TypeError: 'unicode' does not have the buffer interface
Any ideas? :(
pip says that I'm using
Flask-HTTPAuth==2.2.1
Flask-Login==0.2.11
Flask-Mail==0.9.0
Flask-Redis==0.0.5
Flask-SQLAlchemy==1.0
Flask-Script==2.0.5
Flask-WTF==0.9.5
Jinja2==2.7.2
MarkupSafe==0.23
SQLAlchemy==0.9.4
WTForms==2.0
Werkzeug==0.9.4
blinker==1.3
itsdangerous==0.24
redis==2.10.1
wsgiref==0.1.2
and
setuptools (4.0.1)
shuhaowu commented
+1 on this. My production environment is dead now because of this.
shuhaowu commented
Found the issue: On https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/security.py#L133
it uses the builtin hmac.compare_digest
to compare. This is a new method in 2.7.7. The documentation shows that it needs to compare two items that have the same type.
https://docs.python.org/2/library/hmac.html#hmac.compare_digest
wiesson commented
Thanks, works for me!