PR feedback: comment out original inspect.isabstract code

This commit is contained in:
Chris Moradi
2021-11-29 08:56:32 -08:00
parent 5fef0267af
commit 961e700612

7
Lib/inspect.py vendored
View File

@@ -300,15 +300,18 @@ def isroutine(object):
def isabstract(object):
"""Return true if the object is an abstract base class (ABC)."""
# TODO: RUSTPYTHON
# TPFLAGS_IS_ABSTRACT is not being set for abstract classes, so this implementation differs from CPython.
if not isinstance(object, type):
return False
# TODO: RUSTPYTHON
# TPFLAGS_IS_ABSTRACT is not being set for abstract classes, so this implementation differs from CPython.
# if object.__flags__ & TPFLAGS_IS_ABSTRACT:
# return True
if not issubclass(type(object), abc.ABCMeta):
return False
if hasattr(object, '__abstractmethods__'):
# It looks like ABCMeta.__new__ has finished running;
# TPFLAGS_IS_ABSTRACT should have been accurate.
# return False
return bool(getattr(object, '__abstractmethods__'))
# It looks like ABCMeta.__new__ has not finished running yet; we're
# probably in __init_subclass__. We'll look for abstractmethods manually.