Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 095c119

Browse files
committed
Merged revisions 65168 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r65168 | facundo.batista | 2008-07-21 09:28:17 -0500 (Mon, 21 Jul 2008) | 5 lines 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 d68442d commit 095c119

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
@@ -128,18 +128,23 @@ def attr_matches(self, text):
128128
return []
129129
expr, attr = m.group(1, 3)
130130
try:
131-
object = eval(expr, self.namespace)
131+
thisobject = eval(expr, self.namespace)
132132
except Exception:
133133
return []
134-
words = dir(object)
135-
if hasattr(object,'__class__'):
134+
135+
# get the content of the object, except __builtins__
136+
words = dir(thisobject)
137+
if "__builtins__" in words:
138+
words.remove("__builtins__")
139+
140+
if hasattr(thisobject, '__class__'):
136141
words.append('__class__')
137-
words = words + get_class_members(object.__class__)
142+
words.extend(get_class_members(thisobject.__class__))
138143
matches = []
139144
n = len(attr)
140145
for word in words:
141-
if word[:n] == attr and word != "__builtins__":
142-
val = getattr(object, word)
146+
if word[:n] == attr and hasattr(thisobject, word):
147+
val = getattr(thisobject, word)
143148
word = self._callable_postfix(val, "%s.%s" % (expr, word))
144149
matches.append(word)
145150
return matches

0 commit comments

Comments
 (0)