mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-46433: _PyType_GetModuleByDef: handle static types in MRO (GH-30696)
Automerge-Triggered-By: GH:encukou
This commit is contained in:
parent
0d05da1fbf
commit
0ef0853012
5 changed files with 74 additions and 9 deletions
|
@ -1068,6 +1068,22 @@ class Test_ModuleStateAccess(unittest.TestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
increment_count(1, 2, 3)
|
||||
|
||||
def test_get_module_bad_def(self):
|
||||
# _PyType_GetModuleByDef fails gracefully if it doesn't
|
||||
# find what it's looking for.
|
||||
# see bpo-46433
|
||||
instance = self.module.StateAccessType()
|
||||
with self.assertRaises(TypeError):
|
||||
instance.getmodulebydef_bad_def()
|
||||
|
||||
def test_get_module_static_in_mro(self):
|
||||
# Here, the class _PyType_GetModuleByDef is looking for
|
||||
# appears in the MRO after a static type (Exception).
|
||||
# see bpo-46433
|
||||
class Subclass(BaseException, self.module.StateAccessType):
|
||||
pass
|
||||
self.assertIs(Subclass().get_defining_module(), self.module)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue