@@ -51,13 +51,6 @@ static PyObject *Error;
5151PyDoc_STRVAR (setlocale__doc__ ,
5252"(integer,string=None) -> string. Activates/queries locale processing." );
5353
54- /* to record the LC_NUMERIC settings */
55- static PyObject * grouping = NULL ;
56- static PyObject * thousands_sep = NULL ;
57- static PyObject * decimal_point = NULL ;
58- /* if non-null, indicates that LC_NUMERIC is different from "C" */
59- static char * saved_numeric = NULL ;
60-
6154/* the grouping is terminated by either 0 or CHAR_MAX */
6255static PyObject *
6356copy_grouping (char * s )
@@ -167,7 +160,6 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
167160 int category ;
168161 char * locale = NULL , * result ;
169162 PyObject * result_object ;
170- struct lconv * lc ;
171163
172164 if (!PyArg_ParseTuple (args , "i|z:setlocale" , & category , & locale ))
173165 return NULL ;
@@ -183,48 +175,19 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
183175 result_object = PyString_FromString (result );
184176 if (!result_object )
185177 return NULL ;
186- /* record changes to LC_NUMERIC */
187- if (category == LC_NUMERIC || category == LC_ALL ) {
188- if (strcmp (locale , "C" ) == 0 || strcmp (locale , "POSIX" ) == 0 ) {
189- /* user just asked for default numeric locale */
190- if (saved_numeric )
191- free (saved_numeric );
192- saved_numeric = NULL ;
193- } else {
194- /* remember values */
195- lc = localeconv ();
196- Py_XDECREF (grouping );
197- grouping = copy_grouping (lc -> grouping );
198- Py_XDECREF (thousands_sep );
199- thousands_sep = PyString_FromString (lc -> thousands_sep );
200- Py_XDECREF (decimal_point );
201- decimal_point = PyString_FromString (lc -> decimal_point );
202- if (saved_numeric )
203- free (saved_numeric );
204- saved_numeric = strdup (locale );
205- /* restore to "C" */
206- setlocale (LC_NUMERIC , "C" );
207- }
208- }
209178 /* record changes to LC_CTYPE */
210179 if (category == LC_CTYPE || category == LC_ALL )
211180 fixup_ulcase ();
212181 /* things that got wrong up to here are ignored */
213182 PyErr_Clear ();
214183 } else {
215184 /* get locale */
216- /* restore LC_NUMERIC first, if appropriate */
217- if (saved_numeric )
218- setlocale (LC_NUMERIC , saved_numeric );
219185 result = setlocale (category , NULL );
220186 if (!result ) {
221187 PyErr_SetString (Error , "locale query failed" );
222188 return NULL ;
223189 }
224190 result_object = PyString_FromString (result );
225- /* restore back to "C" */
226- if (saved_numeric )
227- setlocale (LC_NUMERIC , "C" );
228191 }
229192 return result_object ;
230193}
@@ -262,20 +225,13 @@ PyLocale_localeconv(PyObject* self)
262225 Py_XDECREF(x)
263226
264227 /* Numeric information */
265- if (saved_numeric ){
266- /* cannot use localeconv results */
267- PyDict_SetItemString (result , "decimal_point" , decimal_point );
268- PyDict_SetItemString (result , "grouping" , grouping );
269- PyDict_SetItemString (result , "thousands_sep" , thousands_sep );
270- } else {
271- RESULT_STRING (decimal_point );
272- RESULT_STRING (thousands_sep );
273- x = copy_grouping (l -> grouping );
274- if (!x )
275- goto failed ;
276- PyDict_SetItemString (result , "grouping" , x );
277- Py_XDECREF (x );
278- }
228+ RESULT_STRING (decimal_point );
229+ RESULT_STRING (thousands_sep );
230+ x = copy_grouping (l -> grouping );
231+ if (!x )
232+ goto failed ;
233+ PyDict_SetItemString (result , "grouping" , x );
234+ Py_XDECREF (x );
279235
280236 /* Monetary information */
281237 RESULT_STRING (int_curr_symbol );
@@ -579,18 +535,6 @@ PyLocale_nl_langinfo(PyObject* self, PyObject* args)
579535 /* Check whether this is a supported constant. GNU libc sometimes
580536 returns numeric values in the char* return value, which would
581537 crash PyString_FromString. */
582- #ifdef RADIXCHAR
583- if (saved_numeric ) {
584- if (item == RADIXCHAR ) {
585- Py_INCREF (decimal_point );
586- return decimal_point ;
587- }
588- if (item == THOUSEP ) {
589- Py_INCREF (thousands_sep );
590- return thousands_sep ;
591- }
592- }
593- #endif
594538 for (i = 0 ; langinfo_constants [i ].name ; i ++ )
595539 if (langinfo_constants [i ].value == item ) {
596540 /* Check NULL as a workaround for GNU libc's returning NULL
0 commit comments