
Where / how do you type the eval() instruction? In IDLE, in the interactive prompt (>) or in a script (test.py)? What is your OS and what is your locale encoding? Synta圎rror: Non-ASCII character '\xc3' in file tcc.py on line 1, but no encoding declared see for details py file rather than an eval() call, I get:
How to evaluate decipher text python code#
Python will default to ASCII as standard encoding if no otherĪnd indeed when trying Merlijn's code in a.


> Since the default source encoding in python2 is latin-1 Since the default source encoding in python2 is latin-1, and that is documented, I'm not sure what additional documentation you want? Your "workarounds" are just the way you need to feed non-latin1 text into Python2. Nonetheless, documenting this explicitly seems a sensible thing to do.Īuthor: R. I understand this might be considered a WONTFIX, as it would change behavior some people might depend on. In python 3.2, this is the result, as utf-8 is used as default source encoding: The same happens for ast.literal_eval - even calling compile() directly. Instead, the string is interpreted as latin-1.

(which is what results from decoding the str with sys.getdefaultencoding()) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128) (which is what would happen if it was in a source file) Synta圎rror: Non-ASCII character '\xc3' in file on line 1, but no encoding declared see for details # in an utf-8 console, so this is equivalent to Benjamin.peterson, pitrou, python-dev, r.david.murray, serhiy.storchaka, valhallasw, vstinnerĬreated on 18:18 by valhallasw, last changed 23:06 by python-dev.
