From: Martin v. Löwis Date: Wed, 18 Aug 2004 13:35:49 +0000 (+0000) Subject: Patch #914291: Restore locale while calling readline. X-Git-Tag: v2.3.5c1~130 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d903fc05344a36d2dc470e5bf93690b784bb6a9d;p=thirdparty%2FPython%2Fcpython.git Patch #914291: Restore locale while calling readline. --- diff --git a/Misc/NEWS b/Misc/NEWS index f6add9259dc0..1cb3487c1c8a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -28,6 +28,8 @@ Core and builtins Extension modules ----------------- +- Patch #914291: Set locale while getting a line from readline. + - Bug #1005308: Define _BSD_TYPES. - Patch #1005568: Use _SC_PAGESIZE on Irix in resourcemoudle. diff --git a/Modules/readline.c b/Modules/readline.c index 1f1b32708721..dea58e4b7686 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -653,6 +653,10 @@ onintr(int sig) 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; PyOS_sighandler_t old_inthandler; @@ -714,6 +718,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; }