mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #25663: Make rlcompleter avoid duplicate global names
This commit is contained in:
parent
bf7b9ede1a
commit
ed92910852
3 changed files with 29 additions and 2 deletions
|
@ -103,13 +103,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 [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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue