On 12 Jul 2012, at 1:54 AM, Alexei Vinidiktov wrote:
> As it turns out submitting any Non-ASCII characters in any form from any
> browser (for example changing a user's name to contain Cyrillic characters)
> results in the same error on GAE with MySQL (haven't tried with data store).
Your strings appear to be encoded as utf-8. The complaining function wants
either unicode or 7-bit ascii, so you'll need to decode your strings
accordingly.
>>> u =
>>> '\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c'.decode('utf-8')
>>> print u
Пользователь
>>> u = '\xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb'.decode('utf-8')
>>> print u
вошёл
Just *why* you can't use utf-8 directly I don't know.
>
> Any sql statement containing Non-ASCII characters returns the same error
> message:
>
> "has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be
> converted to unicode objects before being added."
>
> This error seems to proceed from the Google Python protobuf library.
> http://code.google.com/p/protobuf/source/browse/trunk/python/google/protobuf/pyext/python-proto2.cc?r=395
>
> Haven't found the same error message anywhere else.
>
>
> On Thu, Jul 12, 2012 at 2:57 PM, Alexei Vinidiktov
> <[email protected]> wrote:
> I now have some additional information.
>
> This error only occurs when using Firefox (I have version 13.0.1 on Windows)
> with Russian set as the preferred language in Firefox settings (I've also
> tested with English as preferred language and did't get this error).
>
> It doesn't occur when using any other browsers that I've tested (Chrome,
> Internet Explorer, Opera).
>
> On Thu, Jul 12, 2012 at 1:57 PM, Alexei Vinidiktov
> <[email protected]> wrote:
> Sorry, forgot to mention that I'm using Python 2.7 and web2py 1.99.7 on GAE .
>
>
> On Thu, Jul 12, 2012 at 1:41 PM, Alexei Vinidiktov
> <[email protected]> wrote:
> Hello,
>
> I'm receiving this error when trying to log in to my application:
> ValueError: "INSERT INTO
> auth_event(origin,user_id,description,time_stamp,client_ip)
>
>
>
>
>
> VALUES
> ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c
> 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb',
> '2012-07-12 06:20:04','95.190.89.149');" has type str, but isn't in 7-bit
> ASCII encoding. Non-ASCII strings must be converted to unicode objects before
> being added.
> Can you help me understand what's going on here?
>
> What's the description that is being inserted?