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 <rep...@bugs.python.org>
<http://bugs.python.org/issue19862>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to