[Python-checkins] r87356 - in python/branches/py3k: Misc/NEWS Modules/readline.c

r.david.murray python-checkins at python.org
Sat Dec 18 04:48:32 CET 2010


Author: r.david.murray
Date: Sat Dec 18 04:48:32 2010
New Revision: 87356

Log:
#9907: call rl_initialize early when using editline on OSX

editline rl_initialize apparently discards any mappings done before it
is called, which makes tab revert to file completion instead of inserting
a tab.  So now on OSX we call rl_initialize first if we are using
readline, and then re-read the users .editrc (if any) afterward so they
can still override our defaults.

Patch by Ned Deily, modified by Ronald Oussoren.



Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/readline.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Dec 18 04:48:32 2010
@@ -20,6 +20,9 @@
 Library
 -------
 
+- Issue $9907: Fix tab handling on OSX when using editline by calling
+  rl_initialize first, then setting our custom defaults, then reading .editrc.
+
 - Issue #4188: Avoid creating dummy thread objects when logging operations
   from the threading module (with the internal verbose flag activated).
 

Modified: python/branches/py3k/Modules/readline.c
==============================================================================
--- python/branches/py3k/Modules/readline.c	(original)
+++ python/branches/py3k/Modules/readline.c	Sat Dec 18 04:48:32 2010
@@ -889,6 +889,14 @@
         Py_FatalError("not enough memory to save locale");
 #endif
 
+#ifdef __APPLE__
+    /* the libedit readline emulation resets key bindings etc 
+     * when calling rl_initialize.  So call it upfront
+     */
+    if (using_libedit_emulation)
+        rl_initialize();
+#endif /* __APPLE__ */
+
     using_history();
 
     rl_readline_name = "python";
@@ -920,8 +928,13 @@
      * XXX: A bug in the readline-2.2 library causes a memory leak
      * inside this function.  Nothing we can do about it.
      */
-    rl_initialize();
-
+#ifdef __APPLE__
+    if (using_libedit_emulation)
+	rl_read_init_file(NULL);
+    else
+#endif /* __APPLE__ */
+        rl_initialize();
+    
     RESTORE_LOCALE(saved_locale)
 }
 


More information about the Python-checkins mailing list