mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
bpo-33018: Improve issubclass() error checking and message. (GH-5944)
This improves error message for situations when a non-class is checked w.r.t. an abstract base class.
This commit is contained in:
parent
d93b5161af
commit
40472dd42d
4 changed files with 11 additions and 0 deletions
|
@ -107,6 +107,8 @@ class ABCMeta(type):
|
|||
|
||||
def __subclasscheck__(cls, subclass):
|
||||
"""Override for issubclass(subclass, cls)."""
|
||||
if not isinstance(subclass, type):
|
||||
raise TypeError('issubclass() arg 1 must be a class')
|
||||
# Check cache
|
||||
if subclass in cls._abc_cache:
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue