| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 95036ea commit f6e323c
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -185,6 +185,13 @@ PyAPI_FUNC(int) _Py_GetLocaleconvNumeric( | |||
| 185 | 185 | ||
| 186 | 186 | #ifdef Py_BUILD_CORE | |
| 187 | 187 | PyAPI_FUNC(int) _Py_GetForceASCII(void); | |
| 188 | + | ||
| 189 | + /* Reset "force ASCII" mode (if it was initialized). | ||
| 190 | + | ||
| 191 | + This function should be called when Python changes the LC_CTYPE locale, | ||
| 192 | + so the "force ASCII" mode can be detected again on the new locale | ||
| 193 | + encoding. */ | ||
| 194 | + PyAPI_FUNC(void) _Py_ResetForceASCII(void); | ||
| 188 | 195 | #endif | |
| 189 | 196 | ||
| 190 | 197 | #ifdef __cplusplus | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,6 +191,12 @@ _Py_GetForceASCII(void) | |||
| 191 | 191 | } | |
| 192 | 192 | ||
| 193 | 193 | ||
| 194 | + void | ||
| 195 | + _Py_ResetForceASCII(void) | ||
| 196 | + { | ||
| 197 | + force_ascii = -1; | ||
| 198 | + } | ||
| 199 | + | ||
| 194 | 200 | ||
| 195 | 201 | static int | |
| 196 | 202 | encode_ascii(const wchar_t *text, char **str, | |
@@ -252,6 +258,12 @@ _Py_GetForceASCII(void) | |||
| 252 | 258 | { | |
| 253 | 259 | return 0; | |
| 254 | 260 | } | |
| 261 | + | ||
| 262 | + void | ||
| 263 | + _Py_ResetForceASCII(void) | ||
| 264 | + { | ||
| 265 | + /* nothing to do */ | ||
| 266 | + } | ||
| 255 | 267 | #endif /* !defined(__APPLE__) && !defined(__ANDROID__) && !defined(MS_WINDOWS) */ | |
| 256 | 268 | ||
| 257 | 269 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -523,6 +523,7 @@ defined(HAVE_LANGINFO_H) && defined(CODESET) | |||
| 523 | 523 | char * | |
| 524 | 524 | _Py_SetLocaleFromEnv(int category) | |
| 525 | 525 | { | |
| 526 | + char *res; | ||
| 526 | 527 | #ifdef __ANDROID__ | |
| 527 | 528 | const char *locale; | |
| 528 | 529 | const char **pvar; | |
@@ -569,10 +570,12 @@ _Py_SetLocaleFromEnv(int category) | |||
| 569 | 570 | } | |
| 570 | 571 | } | |
| 571 | 572 | #endif | |
| 572 | - return setlocale(category, utf8_locale); | ||
| 573 | - #else /* __ANDROID__ */ | ||
| 574 | - return setlocale(category, ""); | ||
| 575 | - #endif /* __ANDROID__ */ | ||
| 573 | + res = setlocale(category, utf8_locale); | ||
| 574 | + #else /* !defined(__ANDROID__) */ | ||
| 575 | + res = setlocale(category, ""); | ||
| 576 | + #endif | ||
| 577 | + _Py_ResetForceASCII(); | ||
| 578 | + return res; | ||
| 576 | 579 | } | |
| 577 | 580 | ||
| 578 | 581 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments