diff -r c8cdc2400643 Modules/readline.c --- a/Modules/readline.c Sun May 05 11:34:21 2013 -0500 +++ b/Modules/readline.c Sun May 05 15:42:56 2013 -0700 @@ -70,6 +70,9 @@ int num_matches, int max_length); #endif +/* Memory allocated for rl_completer_word_break_characters. */ +static char *readlinestate_completer_word_break_characters; + /* Exported function to send one line to readline's init file parser */ static PyObject * @@ -371,8 +374,12 @@ if(!PyArg_ParseTuple(args, "s:set_completer_delims", &break_chars)) { return NULL; } - free((void*)rl_completer_word_break_characters); - rl_completer_word_break_characters = strdup(break_chars); + /* Keep a reference to the allocated memory in the module state in case + some other module modifies rl_completer_word_break_characters. */ + free((void*)readlinestate_completer_word_break_characters); + readlinestate_completer_word_break_characters = + rl_completer_word_break_characters = + strdup(break_chars); Py_RETURN_NONE; } @@ -918,7 +925,8 @@ /* Set our completion function */ rl_attempted_completion_function = (CPPFunction *)flex_complete; /* Set Python word break characters */ - rl_completer_word_break_characters = + readlinestate_completer_word_break_characters = + rl_completer_word_break_characters = strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); /* All nonalphanums except '.' */