return False
def _getmembers(object, predicate, getter):
+ results = []
+ processed = set()
+ names = dir(object)
if isclass(object):
mro = (object,) + getmro(object)
+ # add any DynamicClassAttributes to the list of names if object is a class;
+ # this may result in duplicate entries if, for example, a virtual
+ # attribute with the same name as a DynamicClassAttribute exists
+ try:
+ for base in object.__bases__:
+ for k, v in base.__dict__.items():
+ if isinstance(v, types.DynamicClassAttribute):
+ names.append(k)
+ except AttributeError:
+ pass
else:
mro = ()
- results = []
- processed = set()
- names = dir(object)
- # :dd any DynamicClassAttributes to the list of names if object is a class;
- # this may result in duplicate entries if, for example, a virtual
- # attribute with the same name as a DynamicClassAttribute exists
- try:
- for base in object.__bases__:
- for k, v in base.__dict__.items():
- if isinstance(v, types.DynamicClassAttribute):
- names.append(k)
- except AttributeError:
- pass
for key in names:
# First try to get the value via getattr. Some descriptors don't
# like calling their __get__ (see bug #1785), so fall back to
@types.DynamicClassAttribute
def eggs(self):
return 'spam'
+ class B:
+ def __getattr__(self, attribute):
+ return None
self.assertIn(('eggs', 'scrambled'), inspect.getmembers(A))
self.assertIn(('eggs', 'spam'), inspect.getmembers(A()))
+ b = B()
+ self.assertIn(('__getattr__', b.__getattr__), inspect.getmembers(b))
def test_getmembers_static(self):
class A: