diff options
author | Martin Panter <vadmium+py@gmail.com> | 2015-11-24 00:19:10 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2015-11-24 00:19:10 (GMT) |
commit | 450c9881849d5489ff21d77648f2231d0176c0a5 (patch) | |
tree | 7e69a3238d52b657f16761e8c754ec17e9bc479f /Lib/rlcompleter.py | |
parent | f50fe724de181947f73fd6fd1f54bda5415590c9 (diff) | |
parent | 11bb1ad15502849f126af3f35de7eaeebd617fc5 (diff) | |
download | cpython-450c9881849d5489ff21d77648f2231d0176c0a5.zip cpython-450c9881849d5489ff21d77648f2231d0176c0a5.tar.gz cpython-450c9881849d5489ff21d77648f2231d0176c0a5.tar.bz2 |
Issue #25663: Merge rlcompleter fix from 3.5
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r-- | Lib/rlcompleter.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index 02e1fa5..319e826 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -103,9 +103,11 @@ class Completer: """ import keyword matches = [] + seen = {"__builtins__"} n = len(text) for word in keyword.kwlist: if word[:n] == text: + seen.add(word) if word in {'finally', 'try'}: word = word + ':' elif word not in {'False', 'None', 'True', @@ -113,9 +115,10 @@ class Completer: 'else'}: word = word + ' ' matches.append(word) - for nspace in [builtins.__dict__, self.namespace]: + for nspace in [self.namespace, builtins.__dict__]: for word, val in nspace.items(): - if word[:n] == text and word != "__builtins__": + if word[:n] == text and word not in seen: + seen.add(word) matches.append(self._callable_postfix(val, word)) return matches |