diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2022-05-16 16:47:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 16:47:35 (GMT) |
commit | f82b32410ba220165eab7b8d6dcc61a09744512c (patch) | |
tree | 824253b9d10b5cfddea2e62330e5ccc3e0432888 /Lib | |
parent | 518b2389673833887b26a8474eeb9530d17e2b8d (diff) | |
download | cpython-f82b32410ba220165eab7b8d6dcc61a09744512c.zip cpython-f82b32410ba220165eab7b8d6dcc61a09744512c.tar.gz cpython-f82b32410ba220165eab7b8d6dcc61a09744512c.tar.bz2 |
[3.9] gh-92112: Fix crash triggered by an evil custom `mro()` (GH-92113) (GH-92372)
(cherry picked from commit 85354ed78c0edb6d81a2bd53cabc85e547b8b26e)
Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index e5e9f49..a8fe3ef 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -5686,6 +5686,23 @@ class MroTest(unittest.TestCase): class A(metaclass=M): pass + def test_disappearing_custom_mro(self): + """ + gh-92112: A custom mro() returning a result conflicting with + __bases__ and deleting itself caused a double free. + """ + class B: + pass + + class M(DebugHelperMeta): + def mro(cls): + del M.mro + return (B,) + + with self.assertRaises(TypeError): + class A(metaclass=M): + pass + if __name__ == "__main__": unittest.main() |