]> git.ipfire.org Git - thirdparty/Python/cpython.git/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 83c50e359db8d328efb45b472144f110223565f4..901b9cd55f28aea1aa761a5bf947b832f740b4f1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #25203: Failed readline.set_completer_delims() no longer left the
+  module in inconsistent state.
+
 - Issue #19143: platform module now reads Windows version from kernel32.dll to
   avoid compatibility shims.
 
index 244d2608e7b843b7df7359415e0b26eb662b0679..1e98ffb9c22d719b24559f05dfb0f69c1397b02e 100644 (file)
@@ -355,10 +355,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