##// END OF EJS Templates
don't rely on hasattr in utils.dir2...
Jörgen Stenarson -
Show More
@@ -20,8 +20,14 b''
20 def get_class_members(cls):
20 def get_class_members(cls):
21 ret = dir(cls)
21 ret = dir(cls)
22 if hasattr(cls,'__bases__'):
22 if hasattr(cls,'__bases__'):
23 for base in cls.__bases__:
23 try:
24 ret.extend(get_class_members(base))
24 bases = cls.__bases__
25 except AttributeError:
26 # `obj` lied to hasattr (e.g. Pyro), ignore
27 pass
28 else:
29 for base in bases:
30 ret.extend(get_class_members(base))
25 return ret
31 return ret
26
32
27
33
@@ -59,6 +65,9 b' def dir2(obj):'
59 except TypeError:
65 except TypeError:
60 # This will happen if `obj` is a class and not an instance.
66 # This will happen if `obj` is a class and not an instance.
61 pass
67 pass
68 except AttributeError:
69 # `obj` lied to hasatter (e.g. Pyro), ignore
70 pass
62
71
63 # Support for PyCrust-style _getAttributeNames magic method.
72 # Support for PyCrust-style _getAttributeNames magic method.
64 if hasattr(obj, '_getAttributeNames'):
73 if hasattr(obj, '_getAttributeNames'):
@@ -69,6 +78,9 b' def dir2(obj):'
69 # `obj` is a class and not an instance. Ignore
78 # `obj` is a class and not an instance. Ignore
70 # this error.
79 # this error.
71 pass
80 pass
81 except AttributeError:
82 # `obj` lied to hasatter (e.g. Pyro), ignore
83 pass
72
84
73 if may_have_dupes:
85 if may_have_dupes:
74 # eliminate possible duplicates, as some traits may also
86 # eliminate possible duplicates, as some traits may also
General Comments 0
You need to be logged in to leave comments. Login now