[Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.22,2.23
Martin v. L?wis
loewis@users.sourceforge.net
Wed, 05 Sep 2001 10:09:50 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv20171/Modules
Modified Files:
_localemodule.c
Log Message:
Patch #449815: Set filesystemencoding based on CODESET.
Index: _localemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v
retrieving revision 2.22
retrieving revision 2.23
diff -C2 -d -r2.22 -r2.23
*** _localemodule.c 2001/08/15 17:14:33 2.22
--- _localemodule.c 2001/09/05 17:09:48 2.23
***************
*** 154,158 ****
Py_DECREF(ulo);
}
!
static PyObject*
--- 154,161 ----
Py_DECREF(ulo);
}
!
! #if defined(HAVE_LANGINFO_H) && defined(CODESET)
! static int fileencoding_uses_locale = 0;
! #endif
static PyObject*
***************
*** 204,207 ****
--- 207,226 ----
/* 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 (Py_FileSystemDefaultEncoding);
+ Py_FileSystemDefaultEncoding = strdup(codeset);
+ Py_DECREF(enc);
+ } else
+ PyErr_Clear();
+ }
+ #endif
} else {
/* get locale */