PyAPI_FUNC(int) _Py_GetForceASCII(void);
+/* Reset "force ASCII" mode (if it was initialized).
+
+ This function should be called when Python changes the LC_CTYPE locale,
+ so the "force ASCII" mode can be detected again on the new locale
+ encoding. */
+PyAPI_FUNC(void) _Py_ResetForceASCII(void);
+
+
PyAPI_FUNC(int) _Py_GetLocaleconvNumeric(
struct lconv *lc,
PyObject **decimal_point,
}
+void
+_Py_ResetForceASCII(void)
+{
+ force_ascii = -1;
+}
+
+
static int
encode_ascii(const wchar_t *text, char **str,
size_t *error_pos, const char **reason,
{
return 0;
}
+
+void
+_Py_ResetForceASCII(void)
+{
+ /* nothing to do */
+}
#endif /* !defined(__APPLE__) && !defined(__ANDROID__) && !defined(MS_WINDOWS) */
#include "Python-ast.h"
#undef Yield /* undefine macro conflicting with <winbase.h> */
#include "pycore_context.h"
+#include "pycore_fileutils.h"
#include "pycore_hamt.h"
#include "pycore_pathconfig.h"
#include "pycore_pylifecycle.h"
char *
_Py_SetLocaleFromEnv(int category)
{
+ char *res;
#ifdef __ANDROID__
const char *locale;
const char **pvar;
}
}
#endif
- return setlocale(category, utf8_locale);
-#else /* __ANDROID__ */
- return setlocale(category, "");
-#endif /* __ANDROID__ */
+ res = setlocale(category, utf8_locale);
+#else /* !defined(__ANDROID__) */
+ res = setlocale(category, "");
+#endif
+ _Py_ResetForceASCII();
+ return res;
}