diff options
author | Mark Shannon <mark@hotpy.org> | 2022-08-03 17:56:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-03 17:56:24 (GMT) |
commit | 906e4509328917fe9951f85457897f6a841e0529 (patch) | |
tree | 0ee26881b28d07bc0ec00ae72e3af3f8f134f8a6 /Lib/test/test_capi.py | |
parent | 89f52293281b6efc4ef666ef25e677683821f4b9 (diff) | |
download | cpython-906e4509328917fe9951f85457897f6a841e0529.zip cpython-906e4509328917fe9951f85457897f6a841e0529.tar.gz cpython-906e4509328917fe9951f85457897f6a841e0529.tar.bz2 |
GH-92678: Fix tp_dictoffset inheritance. (GH-95596)
* Add test for inheriting explicit __dict__ and weakref.
* Restore 3.10 behavior for multiple inheritance of C extension classes that store their dictionary at the end of the struct.
Diffstat (limited to 'Lib/test/test_capi.py')
-rw-r--r-- | Lib/test/test_capi.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index a88a17d..013229a 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -619,6 +619,25 @@ class CAPITest(unittest.TestCase): with self.assertRaisesRegex(TypeError, msg): t = _testcapi.pytype_fromspec_meta(_testcapi.HeapCTypeMetaclassCustomNew) + def test_multiple_inheritance_ctypes_with_weakref_or_dict(self): + + class Both1(_testcapi.HeapCTypeWithWeakref, _testcapi.HeapCTypeWithDict): + pass + class Both2(_testcapi.HeapCTypeWithDict, _testcapi.HeapCTypeWithWeakref): + pass + + for cls in (_testcapi.HeapCTypeWithDict, _testcapi.HeapCTypeWithDict2, + _testcapi.HeapCTypeWithWeakref, _testcapi.HeapCTypeWithWeakref2): + for cls2 in (_testcapi.HeapCTypeWithDict, _testcapi.HeapCTypeWithDict2, + _testcapi.HeapCTypeWithWeakref, _testcapi.HeapCTypeWithWeakref2): + if cls is not cls2: + class S(cls, cls2): + pass + class B1(Both1, cls): + pass + class B2(Both1, cls): + pass + def test_pytype_fromspec_with_repeated_slots(self): for variant in range(2): with self.subTest(variant=variant): |