This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author valeriy.nov
Recipients valeriy.nov
Date 2013-12-02.15:18:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1385997526.09.0.197144583843.issue19862@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-12-02 15:18:46valeriy.novsetrecipients: + valeriy.nov
2013-12-02 15:18:46valeriy.novsetmessageid: <1385997526.09.0.197144583843.issue19862@psf.upfronthosting.co.za>
2013-12-02 15:18:46valeriy.novlinkissue19862 messages
2013-12-02 15:18:45valeriy.novcreate