[issue10492] test_doctest fails with iso-8859-15 locale
STINNER Victor
report at bugs.python.org
Sat Dec 11 04:38:51 CET 2010
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
You can reproduce the bug with:
$ LANG=fr_FR.iso885915 at euro ./python -c 'import pdb; pdb.Pdb(nosigint=True).run("exec(%r)" % "x=12")'
> /home/haypo/prog/SVN/py3k/Lib/encodings/iso8859_15.py(15)decode()
-> return codecs.charmap_decode(input,errors,decoding_table)
(Pdb) quit
(it should print "x=12" in the backtrace, not ...iso8859_15.py...)
Simplified C backtrace: builtin_exec() -> PyRun_StringFlags() -> PyAST_CompileEx() -> makecode() -> PyUnicode_DecodeFSDefault().
ISO-8859-15 codec is implemented in Python whereas ASCII, ISO-8859-1 and UTF-8 are implemented in C. Pdb stops at the first Python instruction. The user expects that the first instruction is "x=12", but no, the real first Python instruction is calling ISO-8859-15 to decode the byte string "<string>" (script filename).
I see two solutions:
- set the trace function later. Eg. replace exec(cmd, ...) by code=compile(cmd, ...) + exec(code) and set the trace function after the call to compile. I don't know if both codes are equivalent.
- reimplement ISO-8859-15 in Python: it doesn't solve the issue, there are other encodings implemented in Python
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10492>
_______________________________________
More information about the Python-bugs-list
mailing list