summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/rlcompleter.py6
-rw-r--r--Lib/test/test_rlcompleter.py13
-rw-r--r--Misc/NEWS2
3 files changed, 17 insertions, 4 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index d517c0e..568cf36 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -106,6 +106,12 @@ class Completer:
n = len(text)
for word in keyword.kwlist:
if word[:n] == text:
+ if word in {'finally', 'try'}:
+ word = word + ':'
+ elif word not in {'False', 'None', 'True',
+ 'break', 'continue', 'pass',
+ 'else'}:
+ word = word + ' '
matches.append(word)
for nspace in [builtins.__dict__, self.namespace]:
for word, val in nspace.items():
diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py
index d37b620..11a8305 100644
--- a/Lib/test/test_rlcompleter.py
+++ b/Lib/test/test_rlcompleter.py
@@ -67,10 +67,15 @@ class TestRlcompleter(unittest.TestCase):
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')
+ 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 ')
+ self.assertEqual(completer.complete('pa', 0), 'pass')
+ self.assertEqual(completer.complete('Fa', 0), 'False')
+ self.assertEqual(completer.complete('el', 0), 'elif ')
+ self.assertEqual(completer.complete('el', 1), 'else')
+ self.assertEqual(completer.complete('tr', 0), 'try:')
if __name__ == '__main__':
unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
index 38eb843..8d4549a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,8 @@ Core and Builtins
Library
-------
+- Issue #25209: rlcomplete now can add a space or a colon after completed keyword.
+
- Issue #22241: timezone.utc name is now plain 'UTC', not 'UTC-00:00'.
- Issue #23517: fromtimestamp() and utcfromtimestamp() methods of