New submission from Ray.Allen <[email protected]>:
According to PEP 383, the new "surrogateescape" error handler of codecs should
begin to appear since Python3.1, but in the trunk I found some code have
already used it:
Modules/_io/fileio.c:
static int
fileio_init(PyObject *oself, PyObject *args, PyObject *kwds){
...
stringobj = PyUnicode_AsEncodedString(
u, Py_FileSystemDefaultEncoding, "surrogateescape");
...
Obviously, the "surrogateescape" error handler not exists.
Some test code:
===========================
import io
file_name = u'\udc80.txt'
f = io.FileIO(file_name)
===========================
When run this piece of code on a machine whose file system default encoding is
gb2312, will raise an exception:
LookupError: unknown error handler name 'surrogateescape'
I don't know weather this is a bug?
Thanks.
----------
components: Unicode
messages: 103470
nosy: loewis, ysj.ray
severity: normal
status: open
title: Codecs: "surrogateescape" error handler in Python 2.7
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue8438>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com