From: Eli Bendersky Date: Thu, 28 Nov 2013 14:25:45 +0000 (-0800) Subject: Issue #19815: Fix segfault when parsing empty namespace declaration. X-Git-Tag: v2.7.8~233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f933e081ddfb630afe989d2e15b15e5379434ea4;p=python Issue #19815: Fix segfault when parsing empty namespace declaration. Based on patches by Christian Heimes and Vajrasky Kok --- diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index adb785247d..9fb6c998a9 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -713,14 +713,21 @@ def iterparse(): end {namespace}root end-ns None + >>> import StringIO + + >>> events = ('start-ns', 'end-ns') + >>> context = ET.iterparse(StringIO.StringIO(r""), events) + >>> for action, elem in context: + ... print action, elem + start-ns ('', '') + end-ns None + >>> events = ("start", "end", "bogus") >>> with open(SIMPLE_XMLFILE, "rb") as f: ... iterparse(f, events) Traceback (most recent call last): ValueError: unknown event 'bogus' - >>> import StringIO - >>> source = StringIO.StringIO( ... "\\n" ... "