]> granicus.if.org Git - python/commitdiff
Patch #1472854: make the rlcompleter.Completer class usable on non-
authorGeorg Brandl <georg@python.org>
Sun, 30 Apr 2006 18:14:54 +0000 (18:14 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 30 Apr 2006 18:14:54 +0000 (18:14 +0000)
UNIX platforms.

Doc/lib/librlcompleter.tex
Lib/rlcompleter.py
Lib/test/test_sundry.py
Misc/NEWS

index b2a1eba7e1e3f0efdcd75c5c20b5355ffb31d460..cb2ac59c5836eba60013cad4cdc135e1b23efc34 100644 (file)
@@ -2,18 +2,17 @@
          Completion function for GNU readline}
 
 \declaremodule{standard}{rlcompleter}
-  \platform{Unix}
 \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
-\modulesynopsis{Python identifier completion for the GNU readline library.}
+\modulesynopsis{Python identifier completion, suitable for the GNU readline library.}
 
-The \module{rlcompleter} module defines a completion function for
+The \module{rlcompleter} module defines a completion function suitable for
 the \refmodule{readline} module by completing valid Python identifiers
 and keywords.
 
-This module is \UNIX-specific due to its dependence on the
-\refmodule{readline} module.
-
-The \module{rlcompleter} module defines the \class{Completer} class.
+When this module is imported on a \UNIX\ platform with the \module{readline}
+module available, an instance of the \class{Completer} class is automatically
+created and its \method{complete} method is set as the \module{readline}
+completer.
 
 Example:
 
@@ -44,6 +43,9 @@ else:
 \end{verbatim}
 
 
+On platforms without \module{readline}, the \class{Completer} class defined
+by this module can still be used for custom purposes.
+
 \subsection{Completer Objects \label{completer-objects}}
 
 Completer objects have the following method:
index 1d291670f148bfa8d6fbaa3b0fc91d0d604d2e56..dab0cb9eaa394769af1ec094ed977a6526d1cd06 100644 (file)
@@ -39,7 +39,6 @@ used, and this module (and the readline module) are silently inactive.
 
 """
 
-import readline
 import __builtin__
 import __main__
 
@@ -147,4 +146,9 @@ def get_class_members(klass):
             ret = ret + get_class_members(base)
     return ret
 
-readline.set_completer(Completer().complete)
+try:
+    import readline
+except ImportError:
+    pass
+else:
+    readline.set_completer(Completer().complete)
index af13684ef3dd8c2fe6e282b58971404280a1ec21..f19467c7672ccfa16f23a7b3f2f3c822497a5d55 100644 (file)
@@ -50,11 +50,7 @@ import pstats
 import py_compile
 import pydoc
 import rexec
-try:
-    import rlcompleter   # not available on Windows
-except ImportError:
-    if verbose:
-        print "skipping rlcompleter"
+import rlcompleter
 import sched
 import smtplib
 import sndhdr
index bfbdd731386aee7614dc34c1031a3cbc8c03957f..3bd5a1f506097bbc361ccedf25985390c40c804a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -86,6 +86,9 @@ Extension Modules
 Library
 -------
 
+- Patch #1472854: make the rlcompleter.Completer class usable on non-
+  UNIX platforms.
+
 - Patch #1470846: fix urllib2 ProxyBasicAuthHandler.
 
 - Patch #1475231: ``doctest`` has a new ``SKIP`` option, which causes