Author vstinner
Recipients vstinner
Date 2011-09-20.23:02:07
SpamBayes Score 1.47875e-05
Marked as misclassified No
Message-id <1316559729.08.0.724028142076.issue13024@psf.upfronthosting.co.za>
In-reply-to
Content
cgitb module writes its output to sys.stdout by default and so encode its HTML document into stdout encoding, whereas it doesn't specify the HTML encoding.

Moreover it uses stdout error handler. If the locale encoding is ASCII whereas a filename in the traceback contains a non-ASCII character, it fails to encode the non-ASCII characters. Another error handler should be used, xmlcharrefreplace is a good candidate.

To reproduce this issue, use the following script with ASCII locale encoding and a non-ASCII character in name of the current directory:
---
import cgitb
cgitb.enable()
raise ValueError("Hello World")
---

Attached patch uses a workaround similar to the one used in Log._log() from distutils.logging.
History
Date User Action Args
2011-09-20 23:02:09vstinnersetrecipients: + vstinner
2011-09-20 23:02:09vstinnersetmessageid: <1316559729.08.0.724028142076.issue13024@psf.upfronthosting.co.za>
2011-09-20 23:02:08vstinnerlinkissue13024 messages
2011-09-20 23:02:08vstinnercreate