diff options
author | Guido van Rossum <guido@python.org> | 2002-10-09 21:27:33 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-10-09 21:27:33 (GMT) |
commit | 60c8a3aba82b83e8da25e614bee2329f7c74509f (patch) | |
tree | aca59785a43a496ccab95744349b5519e13042a2 /Modules/readline.c | |
parent | 8052f8921e569c5c7c9afff6dc973dde9ec8f2e5 (diff) | |
download | cpython-60c8a3aba82b83e8da25e614bee2329f7c74509f.zip cpython-60c8a3aba82b83e8da25e614bee2329f7c74509f.tar.gz cpython-60c8a3aba82b83e8da25e614bee2329f7c74509f.tar.bz2 |
GNU readline() mistakenly sets the LC_CTYPE locale.
This is evil. Only the user or the app's main() should do this!
We must save and restore the locale around the rl_initialize() call.
Diffstat (limited to 'Modules/readline.c')
-rw-r--r-- | Modules/readline.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c index a2efd47..59ae8eb 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -12,6 +12,15 @@ #include <signal.h> #include <errno.h> +#if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE) +/* GNU readline() mistakenly sets the LC_CTYPE locale. + * This is evil. Only the user or the app's main() should do this! + * We must save and restore the locale around the rl_initialize() call. + */ +#define SAVE_LOCALE +#include <locale.h> +#endif + /* GNU readline definitions */ #undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */ #include <readline/readline.h> @@ -538,6 +547,10 @@ flex_complete(char *text, int start, int end) static void setup_readline(void) { +#ifdef SAVE_LOCALE + char *saved_locale = setlocale(LC_CTYPE, NULL); +#endif + using_history(); rl_readline_name = "python"; @@ -571,6 +584,10 @@ setup_readline(void) * inside this function. Nothing we can do about it. */ rl_initialize(); + +#ifdef SAVE_LOCALE + setlocale(LC_CTYPE, saved_locale); /* Restore locale */ +#endif } |