From f933e081ddfb630afe989d2e15b15e5379434ea4 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Thu, 28 Nov 2013 06:25:45 -0800 Subject: [PATCH] Issue #19815: Fix segfault when parsing empty namespace declaration. Based on patches by Christian Heimes and Vajrasky Kok --- Lib/test/test_xml_etree.py | 11 +++++++++-- Modules/_elementtree.c | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) 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" ... "