Merge fix for Issue #17011 from 3.3

This commit is contained in:
Eli Bendersky 2013-08-03 17:48:41 -07:00
commit b9b6ce6f2c
2 changed files with 18 additions and 2 deletions

View file

@ -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)