Skip to content

Commit 3b0afda

Browse files
committed
Add a regression test for issue 139400
1 parent e1c0470 commit 3b0afda

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_pyexpat.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,21 @@ def resolve_entity(context, base, system_id, public_id):
771771
self.assertEqual(handler_call_args, [("bar", "baz")])
772772

773773

774+
class ParentParserLifetimeTest(unittest.TestCase):
775+
"""
776+
Subparser make use of the parent XML_Parser inside of Expat.
777+
As a result, parent parsers need to outlive subparsers.
778+
Regression test for issue 139400
779+
"""
780+
def test_parent_parser_outlives_its_subparsers(self):
781+
parser = expat.ParserCreate()
782+
subparser = parser.ExternalEntityParserCreate(None)
783+
784+
# Now try to cause garbage collection of the parent parser
785+
# while it's still being referenced by a related subparser
786+
del parser
787+
788+
774789
class ReparseDeferralTest(unittest.TestCase):
775790
def test_getter_setter_round_trip(self):
776791
parser = expat.ParserCreate()

0 commit comments

Comments
 (0)