Merged revisions 65168 via svnmerge from

svn+ssh://pythondev@svn.python.org/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.
........
This commit is contained in:
Benjamin Peterson 2008-07-21 16:32:10 +00:00
parent d68442dc93
commit 095c1199ff
1 changed files with 11 additions and 6 deletions

View File

@ -128,18 +128,23 @@ class Completer:
return [] return []
expr, attr = m.group(1, 3) expr, attr = m.group(1, 3)
try: try:
object = eval(expr, self.namespace) thisobject = eval(expr, self.namespace)
except Exception: except Exception:
return [] return []
words = dir(object)
if hasattr(object,'__class__'): # get the content of the object, except __builtins__
words = dir(thisobject)
if "__builtins__" in words:
words.remove("__builtins__")
if hasattr(thisobject, '__class__'):
words.append('__class__') words.append('__class__')
words = words + get_class_members(object.__class__) words.extend(get_class_members(thisobject.__class__))
matches = [] matches = []
n = len(attr) n = len(attr)
for word in words: for word in words:
if word[:n] == attr and word != "__builtins__": if word[:n] == attr and hasattr(thisobject, word):
val = getattr(object, word) val = getattr(thisobject, word)
word = self._callable_postfix(val, "%s.%s" % (expr, word)) word = self._callable_postfix(val, "%s.%s" % (expr, word))
matches.append(word) matches.append(word)
return matches return matches