[issue19862] Unclear xpath caching for custom namespaces
Валерий
report at bugs.python.org
Mon Dec 2 16:18:46 CET 2013
New submission from Валерий:
Consider repeated executions of a code like this:
>tree = xml.etree.ElementTree.parse( full_name ) # many different files
>report_type = tree.getroot().attrib['Name'] # something changing
>tree.getroot().find( ".//t:Detail", {'t' : report_type} )
There is a _cache variable in \Lib\xml\etree\ElementPath.py:
>def iterfind(elem, path, namespaces=None):
> // ...
> try:
> selector = _cache[path]
> except KeyError:
> // ...
In my code I use the same path (".//t:Detail"), so no KeyError exception is raised and cached (the same) value is used, but full path should be different ('.//{url_one}Detail', './/{url_two}Detail', etc) depending on namespaces dictionary.
----------
components: XML
messages: 205015
nosy: valeriy.nov
priority: normal
severity: normal
status: open
title: Unclear xpath caching for custom namespaces
type: behavior
versions: Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19862>
_______________________________________
More information about the Python-bugs-list
mailing list