From 5e376a7809d7efe014f3f9b967a4554d79e10328 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 3 Aug 2013 23:46:19 +0300 Subject: Issue #18647: Temporary disable the "nothing to repeat" check to make buildbots happy. --- Lib/sre_compile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index 90e3a25..40d2d52 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -358,8 +358,8 @@ def _optimize_unicode(charset, fixup): def _simple(av): # check if av is a "simple" operator lo, hi = av[2].getwidth() - if lo == 0 and hi == MAXREPEAT: - raise error("nothing to repeat") + #if lo == 0 and hi == MAXREPEAT: + # raise error("nothing to repeat") return lo == hi == 1 and av[2][0][0] != SUBPATTERN def _compile_info(code, pattern, flags): -- cgit v0.12 From 3ceaff0777059c770836e817160f6a81b60c7b18 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 4 Aug 2013 01:04:15 +0300 Subject: Issue #16741: Remove testing of implementation artifact. --- Lib/test/test_unicode.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index b8a5f5e..9dc3438 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1718,8 +1718,6 @@ class UnicodeTest(string_tests.CommonTest, self.assertRaises(TypeError, "hello".encode, 42, 42, 42) # Error handling (lone surrogate in PyUnicode_TransformDecimalToASCII()) - self.assertRaises(UnicodeError, int, "\ud800") - self.assertRaises(UnicodeError, int, "\udf00") self.assertRaises(UnicodeError, float, "\ud800") self.assertRaises(UnicodeError, float, "\udf00") self.assertRaises(UnicodeError, complex, "\ud800") -- cgit v0.12 From 2acc525a972b2b6b071eb5b9596ed1390d6d98e0 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sat, 3 Aug 2013 17:47:47 -0700 Subject: Issue #17011: Fix caching of xpath path when namespaces are present. Thanks to Stefan Behnel for the report and proposed solution & test. --- Lib/test/test_xml_etree.py | 14 ++++++++++++++ Lib/xml/etree/ElementPath.py | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 4c2e26f..402bc2d 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1679,6 +1679,20 @@ class ElementFindTest(unittest.TestCase): summarize_list(e.findall(".//{http://effbot.org/ns}tag")), ['{http://effbot.org/ns}tag'] * 3) + def test_findall_different_nsmaps(self): + root = ET.XML(''' + + + + + ''') + nsmap = {'xx': 'X'} + self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 2) + self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 2) + nsmap = {'xx': 'Y'} + self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 1) + self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 2) + def test_bad_find(self): e = ET.XML(SAMPLE_XML) with self.assertRaisesRegex(SyntaxError, 'cannot use absolute path'): diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py index 52e65f0..e7015c7 100644 --- a/Lib/xml/etree/ElementPath.py +++ b/Lib/xml/etree/ElementPath.py @@ -246,10 +246,12 @@ class _SelectorContext: def iterfind(elem, path, namespaces=None): # compile selector pattern + cache_key = (path, None if namespaces is None + else tuple(sorted(namespaces.items()))) if path[-1:] == "/": path = path + "*" # implicit all (FIXME: keep this?) try: - selector = _cache[path] + selector = _cache[cache_key] except KeyError: if len(_cache) > 100: _cache.clear() @@ -269,7 +271,7 @@ def iterfind(elem, path, namespaces=None): token = next() except StopIteration: break - _cache[path] = selector + _cache[cache_key] = selector # execute selector pattern result = [elem] context = _SelectorContext(elem) -- cgit v0.12 From ca97fd305394d48c0050cd230ce41a057fd71636 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sat, 3 Aug 2013 18:52:32 -0700 Subject: Issue #17902: Clarify doc of ElementTree.iterparse --- Doc/library/xml.etree.elementtree.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst index 45a0e7b..00cdacd 100644 --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -384,7 +384,8 @@ Functions and ``"end-ns"`` (the "ns" events are used to get detailed namespace information). If *events* is omitted, only ``"end"`` events are reported. *parser* is an optional parser instance. If not given, the standard - :class:`XMLParser` parser is used. Returns an :term:`iterator` providing + :class:`XMLParser` parser is used. *parser* can only use the default + :class:`TreeBuilder` as a target. Returns an :term:`iterator` providing ``(event, elem)`` pairs. .. note:: -- cgit v0.12