New submission from STINNER Victor <victor.stin...@haypocalc.com>:

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.

----------
components: Library (Lib)
files: cgitb.patch
keywords: patch
messages: 144356
nosy: haypo
priority: normal
severity: normal
status: open
title: cgitb uses stdout encoding
versions: Python 3.3
Added file: http://bugs.python.org/file23218/cgitb.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13024>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to