[Python-checkins] cpython (3.4): Issue #23441: rcompleter now prints a tab character instead of displaying
berker.peksag
python-checkins at python.org
Mon Jul 27 23:08:56 CEST 2015
https://hg.python.org/cpython/rev/82ccdf2df5ac
changeset: 97089:82ccdf2df5ac
branch: 3.4
parent: 97085:d10f7e0cd059
user: Berker Peksag <berker.peksag at gmail.com>
date: Tue Jul 28 00:06:31 2015 +0300
summary:
Issue #23441: rcompleter now prints a tab character instead of displaying
possible completions for an empty word.
Initial patch by Martin Sekera.
files:
Lib/rlcompleter.py | 6 ++++++
Lib/test/test_rlcompleter.py | 12 ++++++++----
Misc/NEWS | 3 +++
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -73,6 +73,12 @@
if self.use_main_ns:
self.namespace = __main__.__dict__
+ if not text.strip():
+ if state == 0:
+ return '\t'
+ else:
+ return None
+
if state == 0:
if "." in text:
self.matches = self.attr_matches(text)
diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py
--- a/Lib/test/test_rlcompleter.py
+++ b/Lib/test/test_rlcompleter.py
@@ -1,4 +1,3 @@
-from test import support
import unittest
import builtins
import rlcompleter
@@ -65,9 +64,14 @@
['egg.{}('.format(x) for x in dir(str)
if x.startswith('s')])
-def test_main():
- support.run_unittest(TestRlcompleter)
+ def test_complete(self):
+ completer = rlcompleter.Completer()
+ self.assertEqual(completer.complete('', 0), '\t')
+ self.assertEqual(completer.complete('a', 0), 'and')
+ self.assertEqual(completer.complete('a', 1), 'as')
+ self.assertEqual(completer.complete('as', 2), 'assert')
+ self.assertEqual(completer.complete('an', 0), 'and')
if __name__ == '__main__':
- test_main()
+ unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -66,6 +66,9 @@
Library
-------
+- Issue #23441: rcompleter now prints a tab character instead of displaying
+ possible completions for an empty word. Initial patch by Martin Sekera.
+
- Issue #17527: Add PATCH to wsgiref.validator. Patch from Luca Sbardella.
- Issue #24683: Fixed crashes in _json functions called with arguments of
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list