[Python-checkins] r68677 - in python/branches/py3k: Lib/inspect.py Lib/test/test_inspect.py
benjamin.peterson
python-checkins at python.org
Sat Jan 17 23:41:19 CET 2009
Author: benjamin.peterson
Date: Sat Jan 17 23:41:18 2009
New Revision: 68677
Log:
Merged revisions 68676 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68676 | benjamin.peterson | 2009-01-17 16:27:54 -0600 (Sat, 17 Jan 2009) | 1 line
fix inspect.isclass() on instances with a custom __getattr__ #1225107
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/inspect.py
python/branches/py3k/Lib/test/test_inspect.py
Modified: python/branches/py3k/Lib/inspect.py
==============================================================================
--- python/branches/py3k/Lib/inspect.py (original)
+++ python/branches/py3k/Lib/inspect.py Sat Jan 17 23:41:18 2009
@@ -63,7 +63,7 @@
Class objects provide these attributes:
__doc__ documentation string
__module__ name of module in which this class was defined"""
- return isinstance(object, type) or hasattr(object, '__bases__')
+ return isinstance(object, type)
def ismethod(object):
"""Return true if the object is an instance method.
Modified: python/branches/py3k/Lib/test/test_inspect.py
==============================================================================
--- python/branches/py3k/Lib/test/test_inspect.py (original)
+++ python/branches/py3k/Lib/test/test_inspect.py Sat Jan 17 23:41:18 2009
@@ -74,7 +74,6 @@
def test_excluding_predicates(self):
self.istest(inspect.isbuiltin, 'sys.exit')
self.istest(inspect.isbuiltin, '[].append')
- self.istest(inspect.isclass, 'mod.StupidGit')
self.istest(inspect.iscode, 'mod.spam.__code__')
self.istest(inspect.isframe, 'tb.tb_frame')
self.istest(inspect.isfunction, 'mod.spam')
@@ -99,6 +98,15 @@
self.assert_(inspect.isroutine(mod.spam))
self.assert_(inspect.isroutine([].count))
+ def test_isclass(self):
+ self.istest(inspect.isclass, 'mod.StupidGit')
+ self.assertTrue(inspect.isclass(list))
+
+ class CustomGetattr(object):
+ def __getattr__(self, attr):
+ return None
+ self.assertFalse(inspect.isclass(CustomGetattr()))
+
def test_get_slot_members(self):
class C(object):
__slots__ = ("a", "b")
More information about the Python-checkins
mailing list