UnicodeDecodeError from a GET-parameter in webapp2
Posted
by
Aneon
on Stack Overflow
See other posts from Stack Overflow
or by Aneon
Published on 2012-10-28T22:37:46Z
Indexed on
2012/10/28
23:01 UTC
Read the original article
Hit count: 164
I'm getting a UnicodeDecodeError when recieving a GET-parameter from webapp2 that contains unicode characters, and then using it to do a NDB query. I get the same error message when manually running a unicode() on the parameter in the handler, so there either seems to be a problem in webapp2's URL routing or I've missed something. Preferably, all GET-parameters should be converted to unicode before getting passed into the handler so I don't need to do manual conversions in all of my handlers. I actually think it's worked before in an earlier version.
The full error message read: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
The GET-parameter contains the following string: göteborg
. It looks fine when I raise an Exception on it, but gives me an error when I (or NDB) use unicode() on it.
EDIT:
In NDB, it fails on the following code: File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\datastore_types.py", line 1562, in PackString
pbvalue.set_stringvalue(unicode(value).encode('utf-8'))
Thanks.
© Stack Overflow or respective owner