Skip to content

Commit

Permalink
fixed to deep introspection when parsing object tree
Browse files Browse the repository at this point in the history
  • Loading branch information
uweschmitt committed Jun 16, 2014
1 parent 5d44174 commit 8961e59
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions qt_object_viewer/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ def type_to_str(t):
return match.groups()[0]


_do_not_recurse_into = (types.MethodType, types.BuiltinMethodType, types.UnboundMethodType,
types.MemberDescriptorType, types.ClassType, types.TypeType)


def interesting_attributes(obj):
for name in dir(obj):
value = getattr(obj, name)
if name.startswith("_"):
continue
if isinstance(value, (types.MethodType, types.BuiltinMethodType, types.UnboundMethodType)):
if isinstance(value, _do_not_recurse_into):
continue
yield name, value

Expand Down Expand Up @@ -56,7 +60,9 @@ def from_(clz, name, obj, parent=None):
type_as_str = type_to_str(type(obj))
if isinstance(obj, (int, float, basestring)):
return Leaf(parent, type_as_str, name, obj)
else: # elif isinstance(obj, (list, tuple, set, dict)):
else:
if isinstance(obj, _do_not_recurse_into):
return Leaf(parent, type_as_str, name, obj)
result = clz(parent, type_as_str, name)
children = []
if isinstance(obj, (list, tuple)):
Expand Down

0 comments on commit 8961e59

Please sign in to comment.