]> granicus.if.org Git - python/commitdiff
Issue #25203: Failed readline.set_completer_delims() no longer left the
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 27 Sep 2015 19:34:59 +0000 (22:34 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 27 Sep 2015 19:34:59 +0000 (22:34 +0300)
 module in inconsistent state.

Misc/NEWS
Modules/readline.c

index a4e5c47ab6f76ee19a49a299d184f40475900238..6793215a310faa4b653d0cea8c296c322b93413d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -81,6 +81,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #25203: Failed readline.set_completer_delims() no longer left the
+  module in inconsistent state.
+
 - Prevent overflow in _Unpickler_Read.
 
 - Issue #25047: The XML encoding declaration written by Element Tree now
index b545bca8a91889220f6de3082641161342d5ea74..ad51349bef192ec8e1b8f1a5760600665e978171 100644 (file)
@@ -427,10 +427,11 @@ set_completer_delims(PyObject *self, PyObject *args)
     /* Keep a reference to the allocated memory in the module state in case
        some other module modifies rl_completer_word_break_characters
        (see issue #17289). */
-    free(completer_word_break_characters);
-    completer_word_break_characters = strdup(break_chars);
-    if (completer_word_break_characters) {
-        rl_completer_word_break_characters = completer_word_break_characters;
+    break_chars = strdup(break_chars);
+    if (break_chars) {
+        free(completer_word_break_characters);
+        completer_word_break_characters = break_chars;
+        rl_completer_word_break_characters = break_chars;
         Py_RETURN_NONE;
     }
     else