summaryrefslogtreecommitdiffstats
path: root/Lib/rlcompleter.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-11-23 23:50:26 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-11-23 23:50:26 (GMT)
commit96bc1757ce5eb25cb536c03aabb06fcbc42b6d27 (patch)
tree8dc64a5b00dab5c0a1d362f61a5b273ee3fc049f /Lib/rlcompleter.py
parentb3d8b594261b06b72f22a203c747a375cb30362d (diff)
downloadcpython-96bc1757ce5eb25cb536c03aabb06fcbc42b6d27.zip
cpython-96bc1757ce5eb25cb536c03aabb06fcbc42b6d27.tar.gz
cpython-96bc1757ce5eb25cb536c03aabb06fcbc42b6d27.tar.bz2
Issue #25663: Make rlcompleter avoid duplicate global names
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r--Lib/rlcompleter.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 73f8d80..7f61c67 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -102,13 +102,16 @@ class Completer:
"""
import keyword
matches = []
+ seen = {"__builtins__"}
n = len(text)
for word in keyword.kwlist:
if word[:n] == text:
+ seen.add(word)
matches.append(word)
- for nspace in [__builtin__.__dict__, self.namespace]:
+ for nspace in [self.namespace, __builtin__.__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