Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions 8 Include/internal/pycore_fileutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(

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,
Expand Down
13 changes: 13 additions & 0 deletions 13 Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ _Py_GetForceASCII(void)
}


void
_Py_ResetForceASCII(void)
{
force_ascii = -1;
}


static int
encode_ascii(const wchar_t *text, char **str,
size_t *error_pos, const char **reason,
Expand Down Expand Up @@ -296,6 +303,12 @@ _Py_GetForceASCII(void)
{
return 0;
}

void
_Py_ResetForceASCII(void)
{
/* nothing to do */
}
#endif /* !defined(__APPLE__) && !defined(__ANDROID__) && !defined(MS_WINDOWS) */


Expand Down
12 changes: 8 additions & 4 deletions 12 Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#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"
Expand Down Expand Up @@ -394,6 +395,7 @@ defined(HAVE_LANGINFO_H) && defined(CODESET)
char *
_Py_SetLocaleFromEnv(int category)
{
char *res;
#ifdef __ANDROID__
const char *locale;
const char **pvar;
Expand Down Expand Up @@ -440,10 +442,12 @@ _Py_SetLocaleFromEnv(int category)
}
}
#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;
}


Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.