diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2018-03-07 07:27:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-07 07:27:01 (GMT) |
commit | fc7df0e664198cb05cafd972f190a18ca422989c (patch) | |
tree | 960e82951c176ac63b1e8891422c013090af5a83 /Lib | |
parent | bc3f2289b9007396bfb7f986bee477b6176c1822 (diff) | |
download | cpython-fc7df0e664198cb05cafd972f190a18ca422989c.zip cpython-fc7df0e664198cb05cafd972f190a18ca422989c.tar.gz cpython-fc7df0e664198cb05cafd972f190a18ca422989c.tar.bz2 |
bpo-32999: Fix ABC.__subclasscheck__ crash (GH-6002)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_abc.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py index af26c1d..6fc3c95 100644 --- a/Lib/test/test_abc.py +++ b/Lib/test/test_abc.py @@ -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 |