mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Patch #804543: strdup saved locales. Backported to 2.3.
This commit is contained in:
parent
add09b4149
commit
f56d015a71
2 changed files with 4 additions and 2 deletions
|
@ -611,7 +611,7 @@ static void
|
||||||
setup_readline(void)
|
setup_readline(void)
|
||||||
{
|
{
|
||||||
#ifdef SAVE_LOCALE
|
#ifdef SAVE_LOCALE
|
||||||
char *saved_locale = setlocale(LC_CTYPE, NULL);
|
char *saved_locale = strdup(setlocale(LC_CTYPE, NULL));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using_history();
|
using_history();
|
||||||
|
@ -652,6 +652,7 @@ setup_readline(void)
|
||||||
|
|
||||||
#ifdef SAVE_LOCALE
|
#ifdef SAVE_LOCALE
|
||||||
setlocale(LC_CTYPE, saved_locale); /* Restore locale */
|
setlocale(LC_CTYPE, saved_locale); /* Restore locale */
|
||||||
|
free(saved_locale);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ Py_Initialize(void)
|
||||||
initialized by other means. Also set the encoding of
|
initialized by other means. Also set the encoding of
|
||||||
stdin and stdout if these are terminals. */
|
stdin and stdout if these are terminals. */
|
||||||
|
|
||||||
saved_locale = setlocale(LC_CTYPE, NULL);
|
saved_locale = strdup(setlocale(LC_CTYPE, NULL));
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
codeset = nl_langinfo(CODESET);
|
codeset = nl_langinfo(CODESET);
|
||||||
if (codeset && *codeset) {
|
if (codeset && *codeset) {
|
||||||
|
@ -250,6 +250,7 @@ Py_Initialize(void)
|
||||||
} else
|
} else
|
||||||
codeset = NULL;
|
codeset = NULL;
|
||||||
setlocale(LC_CTYPE, saved_locale);
|
setlocale(LC_CTYPE, saved_locale);
|
||||||
|
free(saved_locale);
|
||||||
|
|
||||||
if (codeset) {
|
if (codeset) {
|
||||||
sys_stream = PySys_GetObject("stdin");
|
sys_stream = PySys_GetObject("stdin");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue