diff options
author | Christian Heimes <christian@cheimes.de> | 2008-03-03 19:18:51 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-03-03 19:18:51 (GMT) |
commit | be5b30b15f6ba8bb854968db3bd43390676b905b (patch) | |
tree | bc9f50a252ba8ad73136af4273222308a972d3c0 /Lib/inspect.py | |
parent | 180510d29b369b88b0eb8815086162d2d6ef60a7 (diff) | |
download | cpython-be5b30b15f6ba8bb854968db3bd43390676b905b.zip cpython-be5b30b15f6ba8bb854968db3bd43390676b905b.tar.gz cpython-be5b30b15f6ba8bb854968db3bd43390676b905b.tar.bz2 |
Merged revisions 61203-61204 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61203 | christian.heimes | 2008-03-03 13:40:17 +0100 (Mon, 03 Mar 2008) | 3 lines
Initialized merge tracking via "svnmerge" with revisions "1-60195" from
svn+ssh://pythondev@svn.python.org/python/branches/trunk-math
........
r61204 | christian.heimes | 2008-03-03 19:28:04 +0100 (Mon, 03 Mar 2008) | 1 line
Since abc._Abstract was replaces by a new type flags the regression test suite fails. I've added a new function inspect.isabstract(). Is the mmethod fine or should I check if object is a instance of type or subclass of object, too?
........
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index ddd7529..ceaea5a 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -39,12 +39,16 @@ import dis import imp import tokenize import linecache +from abc import ABCMeta from operator import attrgetter from collections import namedtuple # These constants are from Include/code.h. CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 0x1, 0x2, 0x4, 0x8 CO_NESTED, CO_GENERATOR, CO_NOFREE = 0x10, 0x20, 0x40 +# See Include/object.h +TPFLAGS_IS_ABSTRACT = 1 << 20 + # ----------------------------------------------------------- type-checking def ismodule(object): """Return true if the object is a module. @@ -241,6 +245,10 @@ def isgenerator(object): """Return true if the object is a generator object.""" return isinstance(object, types.GeneratorType) +def isabstract(object): + """Return true if the object is an abstract base class (ABC).""" + return object.__flags__ & TPFLAGS_IS_ABSTRACT + 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.""" |