mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-32999: Fix ABC.__subclasscheck__ crash (GH-6002)
This commit is contained in:
parent
bc3f2289b9
commit
fc7df0e664
3 changed files with 45 additions and 12 deletions
|
@ -392,6 +392,24 @@ def test_factory(abc_ABCMeta, abc_get_cache_token):
|
|||
self.assertIsInstance(42, A)
|
||||
self.assertIsInstance(42, (A,))
|
||||
|
||||
def test_issubclass_bad_arguments(self):
|
||||
class A(metaclass=abc_ABCMeta):
|
||||
pass
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
issubclass({}, A) # unhashable
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
issubclass(42, A) # No __mro__
|
||||
|
||||
# Python version supports any iterable as __mro__.
|
||||
# But it's implementation detail and don't emulate it in C version.
|
||||
class C:
|
||||
__mro__ = 42 # __mro__ is not tuple
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
issubclass(C(), A)
|
||||
|
||||
def test_all_new_methods_are_called(self):
|
||||
class A(metaclass=abc_ABCMeta):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue