[Python-checkins] python/dist/src/Modules _localemodule.c,2.38,2.39
loewis@users.sourceforge.net
loewis@users.sourceforge.net
Wed, 05 Mar 2003 07:14:18 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv18533/Modules
Modified Files:
_localemodule.c
Log Message:
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
and not as a side effect of setlocale. Expose it as sys.getfilesystemencoding.
Adjust test case.
Index: _localemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v
retrieving revision 2.38
retrieving revision 2.39
diff -C2 -d -r2.38 -r2.39
*** _localemodule.c 21 Dec 2002 18:34:06 -0000 2.38
--- _localemodule.c 5 Mar 2003 15:13:45 -0000 2.39
***************
*** 162,169 ****
}
- #if defined(HAVE_LANGINFO_H) && defined(CODESET)
- static int fileencoding_uses_locale = 0;
- #endif
-
static PyObject*
PyLocale_setlocale(PyObject* self, PyObject* args)
--- 162,165 ----
***************
*** 214,233 ****
/* things that got wrong up to here are ignored */
PyErr_Clear();
- #if defined(HAVE_LANGINFO_H) && defined(CODESET)
- if (Py_FileSystemDefaultEncoding == NULL)
- fileencoding_uses_locale = 1;
- if (fileencoding_uses_locale) {
- char *codeset = nl_langinfo(CODESET);
- PyObject *enc = NULL;
- if (*codeset && (enc = PyCodec_Encoder(codeset))) {
- /* Release previous file encoding */
- if (Py_FileSystemDefaultEncoding)
- free((char *)Py_FileSystemDefaultEncoding);
- Py_FileSystemDefaultEncoding = strdup(codeset);
- Py_DECREF(enc);
- } else
- PyErr_Clear();
- }
- #endif
} else {
/* get locale */
--- 210,213 ----