ytrstu / webapp-improved

Automatically exported from code.google.com/p/webapp-improved
Other
0 stars 0 forks source link

webapp2.extra.sessions needs ascii encoding for cookie_name and secret_key, because hmac needs ascii #70

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
from __future__ import unicode_literals

import webapp2

myconfig_dict = {}
myconfig_dict['webapp2_extras.sessions'] = {
    'cookie_name' : 'session_cookie'.encode('ascii'),
    'secret_key'  : 'my-super-secret-key-somemorearbitarythingstosay'.encode('ascii')
}

Without the ascii encoding of the cookie_name and the secret_key an exception 
is raised, when using unicode literals.

HMAC can only handle byte (i.e. ascii) strings as explained here: 
http://bugs.python.org/issue5285

Original issue reported on code.google.com by robert.vos on 29 Oct 2012 at 2:08