summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-18 16:39:01 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-18 16:39:01 (GMT)
commite09bc1e8f54620e938b7e076830b872a8daabd2c (patch)
tree79bee47d17f3651373481d90b05e1bcdc46539f3 /Lib/inspect.py
parenta8f75da8f2231a7e313792b74eaf06485f7cb86c (diff)
downloadcpython-e09bc1e8f54620e938b7e076830b872a8daabd2c.zip
cpython-e09bc1e8f54620e938b7e076830b872a8daabd2c.tar.gz
cpython-e09bc1e8f54620e938b7e076830b872a8daabd2c.tar.bz2
Revert part of 13f56cd8dec1 (issue #1785) to avoid breaking getmembers() with unbound methods.
Python 3 isn't affected (unbound methods don't exist). Thanks to Vincent Pelletier for noticing.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py19
1 files changed, 4 insertions, 15 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index cb07b9d..66d5186 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -247,23 +247,12 @@ def isabstract(object):
def getmembers(object, predicate=None):
"""Return all members of an object as (name, value) pairs sorted by name.
Optionally, only return members that satisfy a given predicate."""
- if isclass(object):
- mro = (object,) + getmro(object)
- else:
- mro = ()
results = []
for key in dir(object):
- # First try to get the value via __dict__. Some descriptors don't
- # like calling their __get__ (see bug #1785).
- for base in mro:
- if key in base.__dict__:
- value = base.__dict__[key]
- break
- else:
- try:
- value = getattr(object, key)
- except AttributeError:
- continue
+ try:
+ value = getattr(object, key)
+ except AttributeError:
+ continue
if not predicate or predicate(value):
results.append((key, value))
results.sort()