File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ What's New in Python 3.0 beta 5
1515Core and Builtins
1616-----------------
1717
18+ - Issue #4213: The file system encoding is now normalized by the
19+ codec subsystem, for example UTF-8 is turned into utf-8.
20+
1821- Issue #4200: Changed the atexit module to store its state in its
1922 PyModuleDef atexitmodule. This fixes a bug with multiple subinterpeters.
2023
Original file line number Diff line number Diff line change @@ -126,6 +126,37 @@ add_flag(int flag, const char *envs)
126126 return flag ;
127127}
128128
129+ #if defined(HAVE_LANGINFO_H ) && defined(CODESET )
130+ static char *
131+ get_codeset (void )
132+ {
133+ char * codeset ;
134+ PyObject * codec , * name ;
135+
136+ codeset = nl_langinfo (CODESET );
137+ if (!codeset || codeset [0 ] == '\0' )
138+ return NULL ;
139+
140+ codec = _PyCodec_Lookup (codeset );
141+ if (!codec )
142+ goto error ;
143+
144+ name = PyObject_GetAttrString (codec , "name" );
145+ Py_CLEAR (codec );
146+ if (!name )
147+ goto error ;
148+
149+ codeset = strdup (_PyUnicode_AsString (name ));
150+ Py_DECREF (name );
151+ return codeset ;
152+
153+ error :
154+ Py_XDECREF (codec );
155+ PyErr_Clear ();
156+ return NULL ;
157+ }
158+ #endif
159+
129160void
130161Py_InitializeEx (int install_sigs )
131162{
@@ -257,15 +288,7 @@ Py_InitializeEx(int install_sigs)
257288 initialized by other means. Also set the encoding of
258289 stdin and stdout if these are terminals. */
259290
260- codeset = nl_langinfo (CODESET );
261- if (codeset && * codeset ) {
262- if (PyCodec_KnownEncoding (codeset ))
263- codeset = strdup (codeset );
264- else
265- codeset = NULL ;
266- } else
267- codeset = NULL ;
268-
291+ codeset = get_codeset ();
269292 if (codeset ) {
270293 if (!Py_FileSystemDefaultEncoding )
271294 Py_FileSystemDefaultEncoding = codeset ;
You can’t perform that action at this time.
0 commit comments