summaryrefslogtreecommitdiffstats
path: root/Modules/readline.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2004-08-18 13:34:00 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2004-08-18 13:34:00 (GMT)
commit78a8acc55bb3ae7c8d265cbcb4709d84938a4cef (patch)
treef3cc9d050f8f802db8720a15e9e4a8e3d8f4d120 /Modules/readline.c
parentae075b6cb7830fab2ee103441fd2549fb282643f (diff)
downloadcpython-78a8acc55bb3ae7c8d265cbcb4709d84938a4cef.zip
cpython-78a8acc55bb3ae7c8d265cbcb4709d84938a4cef.tar.gz
cpython-78a8acc55bb3ae7c8d265cbcb4709d84938a4cef.tar.bz2
Patch #914291: Restore locale while readline is running.
Diffstat (limited to 'Modules/readline.c')
-rw-r--r--Modules/readline.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c
index 40d489f..5e771d9 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -821,6 +821,10 @@ readline_until_enter_or_signal(char *prompt, int *signal)
static char *
call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
{
+#ifdef SAVE_LOCALE
+ char *saved_locale = strdup(setlocale(LC_CTYPE, NULL));
+ setlocale(LC_CTYPE, "");
+#endif
size_t n;
char *p, *q;
int signal;
@@ -879,6 +883,10 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
p[n+1] = '\0';
}
free(q);
+#ifdef SAVE_LOCALE
+ setlocale(LC_CTYPE, saved_locale); /* Restore locale */
+ free(saved_locale);
+#endif
return p;
}