diff options
author | Larry Hastings <larry@hastings.org> | 2013-08-04 06:30:13 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2013-08-04 06:30:13 (GMT) |
commit | b90f417d696c667017f3fa80d37861a69acee24f (patch) | |
tree | 26db853b62c21393926013357f9bf3334bfdf170 | |
parent | a3c6a1fb6f54d751be76c9c23a8a31393c035518 (diff) | |
parent | c4216ab92be06368a9edc4416b20ee5c9304ef3d (diff) | |
download | cpython-b90f417d696c667017f3fa80d37861a69acee24f.zip cpython-b90f417d696c667017f3fa80d37861a69acee24f.tar.gz cpython-b90f417d696c667017f3fa80d37861a69acee24f.tar.bz2 |
Merging the 3.4.0a1 head.
-rw-r--r-- | Doc/library/xml.etree.elementtree.rst | 5 | ||||
-rw-r--r-- | Lib/sre_compile.py | 4 | ||||
-rw-r--r-- | Lib/test/test_unicode.py | 2 | ||||
-rw-r--r-- | Lib/test/test_xml_etree.py | 14 | ||||
-rw-r--r-- | Lib/xml/etree/ElementPath.py | 6 |
5 files changed, 23 insertions, 8 deletions
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst index d0bfed0..c0cc683 100644 --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -416,7 +416,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 that while :func:`iterparse` builds the tree incrementally, it issues @@ -880,7 +881,7 @@ IncrementalParser Objects 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. + used. *parser* can only use the default :class:`TreeBuilder` as a target. .. method:: data_received(data) diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index ea6e6be..429d779 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -351,8 +351,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): diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 00c0fff..9e53213 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1735,8 +1735,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") diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index e2ffc19..dec25b5 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1839,6 +1839,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(''' + <a xmlns:x="X" xmlns:y="Y"> + <x:b><c/></x:b> + <b/> + <c><x:b/><b/></c><y:b/> + </a>''') + 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 bf984b9..d914ddb 100644 --- a/Lib/xml/etree/ElementPath.py +++ b/Lib/xml/etree/ElementPath.py @@ -249,10 +249,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() @@ -272,7 +274,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) |