gh-139748: fix leaks in AC error paths when using unicode FS-based converters (#139765)

This commit is contained in:
Bénédikt Tran 2025-10-08 17:22:44 +02:00 committed by GitHub
parent 570d17259f
commit b04a57deef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 88 additions and 46 deletions

View file

@ -579,6 +579,13 @@ def test_nested_genexpr(self):
self.assertEqual(sorted(st.get_identifiers()), [".0", "y"])
self.assertEqual(st.get_children(), [])
def test__symtable_refleak(self):
# Regression test for reference leak in PyUnicode_FSDecoder.
# See https://github.com/python/cpython/issues/139748.
mortal_str = 'this is a mortal string'
# check error path when 'compile_type' AC conversion failed
self.assertRaises(TypeError, symtable.symtable, '', mortal_str, 1)
class ComprehensionTests(unittest.TestCase):
def get_identifiers_recursive(self, st, res):