Author vstinner
Recipients vstinner
Date 2008-09-26.15:12:27
SpamBayes Score 2.81845e-10
Marked as misclassified No
Message-id <1222441949.55.0.46817952378.issue3975@psf.upfronthosting.co.za>
In-reply-to
Content
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?).
History
Date User Action Args
2008-09-26 15:12:29vstinnersetrecipients: + vstinner
2008-09-26 15:12:29vstinnersetmessageid: <1222441949.55.0.46817952378.issue3975@psf.upfronthosting.co.za>
2008-09-26 15:12:28vstinnerlinkissue3975 messages
2008-09-26 15:12:27vstinnercreate