summaryrefslogtreecommitdiffstats
path: root/Lib/rlcompleter.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r--Lib/rlcompleter.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 26f5920..401a626 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -75,9 +75,12 @@ class Completer:
if not text.strip():
if state == 0:
- readline.insert_text('\t')
- readline.redisplay()
- return ''
+ if _readline_available:
+ readline.insert_text('\t')
+ readline.redisplay()
+ return ''
+ else:
+ return '\t'
else:
return None
@@ -170,10 +173,11 @@ def get_class_members(klass):
try:
import readline
except ImportError:
- pass
+ _readline_available = False
else:
readline.set_completer(Completer().complete)
# Release references early at shutdown (the readline module's
# contents are quasi-immortal, and the completer function holds a
# reference to globals).
atexit.register(lambda: readline.set_completer(None))
+ _readline_available = True