mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
[3.10] gh-92112: Fix crash triggered by an evil custom mro()
(GH-92113) (#92370)
(cherry picked from commit 85354ed78c
)
Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
This commit is contained in:
parent
17f3b5cbfa
commit
4674b315e5
3 changed files with 29 additions and 9 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue