[Python-checkins] r69660 - python/branches/io-c/Modules/_textio.c
benjamin.peterson
python-checkins at python.org
Mon Feb 16 04:09:31 CET 2009
Author: benjamin.peterson
Date: Mon Feb 16 04:09:31 2009
New Revision: 69660
Log:
apparently locale.getprefferedencoding() can raise a ImportError, too
Modified:
python/branches/io-c/Modules/_textio.c
Modified: python/branches/io-c/Modules/_textio.c
==============================================================================
--- python/branches/io-c/Modules/_textio.c (original)
+++ python/branches/io-c/Modules/_textio.c Mon Feb 16 04:09:31 2009
@@ -789,9 +789,15 @@
use_locale:
self->encoding = PyObject_CallMethod(
state->locale_module, "getpreferredencoding", NULL);
- if (self->encoding == NULL)
- goto error;
- if (!PyUnicode_Check(self->encoding))
+ if (self->encoding == NULL) {
+ if (PyErr_ExceptionMatches(PyExc_ImportError)) {
+ PyErr_Clear();
+ self->encoding = PyUnicode_FromString("ascii");
+ }
+ else
+ goto error;
+ }
+ else if (!PyUnicode_Check(self->encoding))
Py_CLEAR(self->encoding);
}
}
More information about the Python-checkins
mailing list