Skip to content

Commit f3f6759

Browse files
Issue 3396. Fixed the autocompletion of 'int.', and worked
a little that part of the code, fixing a detail and enhancing a bit others.
1 parent fa26782 commit f3f6759

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

β€ŽLib/rlcompleter.pyβ€Ž

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,23 @@ def attr_matches(self, text):
134134
return []
135135
expr, attr = m.group(1, 3)
136136
try:
137-
object = eval(expr, self.namespace)
137+
thisobject = eval(expr, self.namespace)
138138
except Exception:
139139
return []
140-
words = dir(object)
141-
if hasattr(object,'__class__'):
140+
141+
# get the content of the object, except __builtins__
142+
words = dir(thisobject)
143+
if "__builtins__" in words:
144+
words.remove("__builtins__")
145+
146+
if hasattr(thisobject, '__class__'):
142147
words.append('__class__')
143-
words = words + get_class_members(object.__class__)
148+
words.extend(get_class_members(thisobject.__class__))
144149
matches = []
145150
n = len(attr)
146151
for word in words:
147-
if word[:n] == attr and word != "__builtins__":
148-
val = getattr(object, word)
152+
if word[:n] == attr and hasattr(thisobject, word):
153+
val = getattr(thisobject, word)
149154
word = self._callable_postfix(val, "%s.%s" % (expr, word))
150155
matches.append(word)
151156
return matches

0 commit comments

Comments
 (0)