File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -718,6 +718,24 @@ def test_expaterror(self):
718718 self .assertEqual (e .code ,
719719 errors .codes [errors .XML_ERROR_UNCLOSED_TOKEN ])
720720
721+ class ElementDeclHandlerCleanUpLeakTest (unittest .TestCase ):
722+
723+ def test_trigger_leak (self ):
724+ # Unfixed, this test would leak 32 to 56 bytes of memory
725+ # https://github.com/python/cpython/issues/140593
726+ data = textwrap .dedent ('''\
727+ <!DOCTYPE quotations SYSTEM "quotations.dtd" [
728+ <!ELEMENT root ANY>
729+ ]>
730+ <root/>
731+ ''' ).encode ('UTF-8' )
732+
733+ parser = expat .ParserCreate ()
734+ parser .NotStandaloneHandler = lambda : 1.234 # arbitrary float
735+ parser .ElementDeclHandler = lambda _1 , _2 : None
736+ with self .assertRaises (TypeError ):
737+ parser .Parse (data , True )
738+
721739
722740class ForeignDTDTests (unittest .TestCase ):
723741 """
You can’t perform that action at this time.
0 commit comments