changeset: 97090:d55bdd2dc45e branch: 3.5 parent: 97086:401bb7ceb7e8 parent: 97089:82ccdf2df5ac user: Berker Peksag date: Tue Jul 28 00:08:24 2015 +0300 files: Lib/test/test_rlcompleter.py Misc/NEWS description: Issue #23441: rcompleter now prints a tab character instead of displaying possible completions for an empty word. Initial patch by Martin Sekera. diff -r 401bb7ceb7e8 -r d55bdd2dc45e Lib/rlcompleter.py --- a/Lib/rlcompleter.py Mon Jul 27 16:48:06 2015 +0300 +++ b/Lib/rlcompleter.py Tue Jul 28 00:08:24 2015 +0300 @@ -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 -r 401bb7ceb7e8 -r d55bdd2dc45e Lib/test/test_rlcompleter.py --- a/Lib/test/test_rlcompleter.py Mon Jul 27 16:48:06 2015 +0300 +++ b/Lib/test/test_rlcompleter.py Tue Jul 28 00:08:24 2015 +0300 @@ -64,5 +64,13 @@ ['egg.{}('.format(x) for x in dir(str) if x.startswith('s')]) + 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__': unittest.main() diff -r 401bb7ceb7e8 -r d55bdd2dc45e Misc/NEWS --- a/Misc/NEWS Mon Jul 27 16:48:06 2015 +0300 +++ b/Misc/NEWS Tue Jul 28 00:08:24 2015 +0300 @@ -42,6 +42,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 #24683: Fixed crashes in _json functions called with arguments of inappropriate type.