New submission from STINNER Victor <victor.stinner@haypocalc.com>:
PyTraceBack_Print() doesn't take care of the "# coding: xxx" header of
a Python script. It calls _Py_DisplaySourceLine() which opens the file
as a byte stream (and not an unicode characters stream). Because of
this problem, the traceback maybe truncated or invalid. Example (write
it into a file and execute the file):
----
from sys import executable
from os import execvpe
filename = "pouet.py"
out = open(filename, "wb")
out.write(b"""# -*- coding: GBK -*-
print("--asc\xA1\xA7i--")
raise Exception("--asc\xA1\xA7i--")""")
out.close()
execvpe(executable, [executable, filename], None)
----
This issue depends on issue2384 (line number).
Note: Python 2.6 may also has the problem but it doesn't parse "#
coding: GBK". So it's a different problem (issue?).
----------
messages: 73851
nosy: haypo
severity: normal
status: open
title: PyTraceBack_Print() doesn't respect # coding: xxx header
versions: Python 3.0
_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue3975>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
PyTraceBack_Print() doesn't take care of the "# coding: xxx" header of
a Python script. It calls _Py_DisplaySourceLine() which opens the file
as a byte stream (and not an unicode characters stream). Because of
this problem, the traceback maybe truncated or invalid. Example (write
it into a file and execute the file):
----
from sys import executable
from os import execvpe
filename = "pouet.py"
out = open(filename, "wb")
out.write(b"""# -*- coding: GBK -*-
print("--asc\xA1\xA7i--")
raise Exception("--asc\xA1\xA7i--")""")
out.close()
execvpe(executable, [executable, filename], None)
----
This issue depends on issue2384 (line number).
Note: Python 2.6 may also has the problem but it doesn't parse "#
coding: GBK". So it's a different problem (issue?).
----------
messages: 73851
nosy: haypo
severity: normal
status: open
title: PyTraceBack_Print() doesn't respect # coding: xxx header
versions: Python 3.0
_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue3975>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com