Merge 3.5
This commit is contained in:
commit
ab8d4fba6d
|
@ -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
|
||||
|
||||
|
@ -192,10 +195,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
|
||||
|
|
|
@ -101,6 +101,7 @@ class TestRlcompleter(unittest.TestCase):
|
|||
completer = rlcompleter.Completer(dict(f=Foo()))
|
||||
self.assertEqual(completer.complete('f.', 0), 'f.bar')
|
||||
|
||||
@unittest.mock.patch('rlcompleter._readline_available', False)
|
||||
def test_complete(self):
|
||||
completer = rlcompleter.Completer()
|
||||
self.assertEqual(completer.complete('', 0), '\t')
|
||||
|
|
Loading…
Reference in New Issue