classification
Title: ElementPath ignores different namespace mappings for the same path expression
Type: behavior Stage: resolved
Components: Library (Lib), XML Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eli.bendersky, python-dev, scoder, silverbacknet
Priority: normal Keywords:

Created on 2013-01-22 07:16 by scoder, last changed 2013-12-06 17:39 by eric.araujo. This issue is now closed.

Messages (4)
msg180366 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2013-01-22 07:16
There's a bug originally report for lxml that also applies to ElementTree:

https://github.com/lxml/lxml/issues/95

Passing different namespace mappings into the Element.find*() methods will always reuse the first one due to incorrect caching based only on the literal path, not all parameters. My fix is here:

https://github.com/lxml/lxml/commit/8bafbdc13ffb4fb8436eda01594780aac4735528

The lookup performance regression when a namespace mapping is passed (sorting etc.) is acceptable as most use cases won't pass any namespaces anyway, so this is a problem that rarely shows in practice.
msg180367 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2013-01-22 07:25
Here is a test case (for lxml):

https://github.com/lxml/lxml/commit/76f2ee991afd15d4f8c98cee3e095967bbf9937f
msg194316 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-04 00:49
New changeset 854ded9135c2 by Eli Bendersky in branch '3.3':
Issue #17011: Fix caching of xpath path when namespaces are present.
http://hg.python.org/cpython/rev/854ded9135c2

New changeset ce0be0d03c0a by Eli Bendersky in branch 'default':
Merge fix for Issue #17011 from 3.3
http://hg.python.org/cpython/rev/ce0be0d03c0a
msg194317 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2013-08-04 00:49
Fixed. Thanks!
History
Date User Action Args
2013-12-06 17:39:19eric.araujosetresolution: duplicate -> fixed
2013-12-06 17:39:08eric.araujosetresolution: fixed -> duplicate
2013-08-04 00:49:28eli.benderskysetstatus: open -> closed
resolution: fixed
messages: + msg194317

stage: resolved
2013-08-04 00:49:02python-devsetnosy: + python-dev
messages: + msg194316
2013-01-31 02:15:34silverbacknetsetnosy: + silverbacknet
2013-01-22 09:07:34serhiy.storchakasetnosy: + eli.bendersky
2013-01-22 07:25:12scodersetmessages: + msg180367
2013-01-22 07:16:47scodersetcomponents: + XML
2013-01-22 07:16:36scodersetcomponents: + Library (Lib), - XML
2013-01-22 07:16:24scodercreate