Gendrop / webapp-improved

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

serialize(name, value) is not working on binary string #101

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
https://webapp-improved.appspot.com/api/webapp2_extras/securecookie.html
What steps will reproduce the problem?
      cookieSerializer = securecookie.SecureCookieSerializer(configuration.Configuration.secretKey)
      serialized = cookieSerializer.serialize(IDENTIFICATION_COOKIE_NAME, os.urandom(32))
      self.response.set_cookie(IDENTIFICATION_COOKIE_NAME, serialized, 
                               max_age = IDENTIFICATION_MAX_COOKIE_AGE, 
                               path = IDENTIFICATION_COOKIE_PATH)

What is the expected output? What do you see instead?
Value should be serialized.

  File "C:\Users\Crezary Wagner\workspace-eclipse-3-8-pydev\web-core\src\web_core\frontend\handler\identification.py", line 22, in dispatch

    serialized = cookieSerializer.serialize(IDENTIFICATION_COOKIE_NAME, os.urandom(32))

  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2_extras\securecookie.py", line 47, in serialize

    value = self._encode(value)

  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2_extras\securecookie.py", line 92, in _encode

    return json.b64encode(value)

  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2_extras\json.py", line 84, in b64encode

    return base64.b64encode(encode(value, *args, **kwargs))

  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2_extras\json.py", line 55, in encode

    return json.dumps(value, *args, **kwargs).replace("</", "<\\/")

  File "C:\root\Python27\lib\json\__init__.py", line 250, in dumps

    sort_keys=sort_keys, **kw).encode(obj)

  File "C:\root\Python27\lib\json\encoder.py", line 201, in encode

    return encode_basestring_ascii(o)

UnicodeDecodeError: 'utf8' codec can't decode byte 0x84 in position 0: invalid 
start byte

What version of the product are you using? On what operating system?
Webapp2 win32 2.5.2

Please provide any additional information below.

Original issue reported on code.google.com by Cezary.W...@gmail.com on 17 May 2015 at 7:46