Skip to content

🐛 fix(xpath): allow an operator name after a * test - #1085

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/xpath-operator-after-star
Oct 3, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/xpath-operator-after-star

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

xpath() rejected or, and, div and mod used as operators right after a * name test, and the expressions css_to_xpath emits for :has() tripped the same error, because the lexer always put the token after * in value position.
A * is a NameTest in value position and a MultiplyOperator in operator position per the XPath 1.0 lexical structure, so the token after a * NameTest is now an operator, and //* or 1, (* or 1) and descendant::* or descendant::p evaluate as lxml evaluates them.

//* or 1, (* or 1) and descendant::* or descendant::p now evaluate as they do in lxml, Saxon-HE 13 and elementpath. libxml2 parses div and mod only after a complete unary expression, and elementpath reads an operator name as a name only in prefix position.

closes #1039

@gaborbernat gaborbernat added the bug Something isn't working label Oct 3, 2026
@gaborbernat
gaborbernat force-pushed the fix/xpath-operator-after-star branch from cd930f0 to 22ab41b Compare October 3, 2026 10:03
@codspeed

codspeed Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 6.11%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 579 untouched benchmarks
⏩ 32 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_feature[select-relative-sibling] 45.6 µs 42.8 µs +6.57%
⚡ test_feature[transform-number-count-last] 585.5 µs 554.2 µs +5.64%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing gaborbernat:fix/xpath-operator-after-star (ad8dd53) with main (48ae9ac)

Open in CodSpeed

Footnotes

  1. 32 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@gaborbernat
gaborbernat force-pushed the fix/xpath-operator-after-star branch from 22ab41b to ad8dd53 Compare October 3, 2026 13:07
@gaborbernat
gaborbernat merged commit d9d1a03 into tox-dev:main Oct 3, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XPath rejects or/and/div/mod after a * name test

1 participant