lxml >= 5.1.1: SyntaxError: cannot use absolute path on element

Bug #2059977 reported by AustinMatherne
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Low
scoder

Bug Description

After updating to versions 5.1.1 and 5.2.0, our codebase encounters exceptions when using absolute paths with the iterfind method of an ElementTree object. This behavior deviates from the expected, where a FutureWarning should be logged instead of raising an exception directly.

Expected Behavior:
Absolute paths should trigger a FutureWarning indicating that absolute paths should not be used without interrupting the execution flow.

Actual Behavior:
A SyntaxError exception is raised, which prevents further execution of the script.

Affected Methods:
ElementTree.iterfind raises an exception when used with an absolute path.

Environment tested with:
Python version: 3.12.2
lxml versions: 5.1.1 and 5.2.0

Attachments:
Python script to reproduce the exception.

Steps to Reproduce:
Use the lxml library version 5.1.1 or 5.2.0.
Run the following Python script:

```python
from lxml import etree

xml_string = """
<concept>
    <concept>Content 1</concept>
    <concept>Content 2</concept>
</concept>
"""

root_tree = etree.fromstring(xml_string).getroottree()
root_tree.iterfind("//concept")

```

Revision history for this message
AustinMatherne (austinmatherne) wrote :
description: updated
Revision history for this message
scoder (scoder) wrote :
Changed in lxml:
assignee: nobody → scoder (scoder)
importance: Undecided → Low
status: New → Fix Committed
milestone: none → 5.1.2
Revision history for this message
scoder (scoder) wrote :
Revision history for this message
scoder (scoder) wrote :

I'll first release this in lxml 5.2.1. The 5.1.2 release doesn't seem urgent, given that this is a) something that users shouldn't do and b) easy to resolve on user side.

scoder (scoder)
Changed in lxml:
milestone: 5.1.2 → 5.2.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.