summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2022-05-07 04:01:23 (GMT)
committerGitHub <noreply@github.com>2022-05-07 04:01:23 (GMT)
commit4674b315e555828e5cb15bedcf2c495669670cbb (patch)
tree6e8024c47bff12cc18d22b4cf78e51d68f5a17a3 /Lib/test
parent17f3b5cbfaada66b45422e80c06b0c5f8157a736 (diff)
downloadcpython-4674b315e555828e5cb15bedcf2c495669670cbb.zip
cpython-4674b315e555828e5cb15bedcf2c495669670cbb.tar.gz
cpython-4674b315e555828e5cb15bedcf2c495669670cbb.tar.bz2
[3.10] gh-92112: Fix crash triggered by an evil custom `mro()` (GH-92113) (#92370)
(cherry picked from commit 85354ed78c0edb6d81a2bd53cabc85e547b8b26e) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_descr.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index f3dd1b3..b174e71 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -5737,6 +5737,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()