[Python-checkins] r84694 - python/branches/py3k/Modules/main.c
victor.stinner
python-checkins at python.org
Sat Sep 11 01:13:52 CEST 2010
Author: victor.stinner
Date: Sat Sep 11 01:13:52 2010
New Revision: 84694
Log:
Issue #8589: surrogateescape error handler is not available at startup
Py_Main() uses _Py_wchar2char() + PyUnicode_FromWideChar() instead of
PyUnicode_DecodeFSDefault(), because the PyCodec machinery is not ready yet.
Modified:
python/branches/py3k/Modules/main.c
Modified: python/branches/py3k/Modules/main.c
==============================================================================
--- python/branches/py3k/Modules/main.c (original)
+++ python/branches/py3k/Modules/main.c Sat Sep 11 01:13:52 2010
@@ -488,7 +488,8 @@
#else
if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') {
char *buf, *oldloc;
- PyObject *warning;
+ wchar_t *wchar;
+ PyObject *unicode;
/* settle for strtok here as there's no one standard
C89 wcstok */
@@ -500,11 +501,15 @@
oldloc = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "");
for (p = strtok(buf, ","); p != NULL; p = strtok(NULL, ",")) {
- warning = PyUnicode_DecodeFSDefault(p);
- if (warning != NULL) {
- PySys_AddWarnOptionUnicode(warning);
- Py_DECREF(warning);
- }
+ wchar = _Py_char2wchar(p);
+ if (wchar == NULL)
+ continue;
+ unicode = PyUnicode_FromWideChar(wchar, wcslen(wchar));
+ PyMem_Free(wchar);
+ if (unicode == NULL)
+ continue;
+ PySys_AddWarnOptionUnicode(unicode);
+ Py_DECREF(unicode);
}
setlocale(LC_ALL, oldloc);
free(oldloc);
More information about the Python-checkins
mailing list