Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #161808.
ElementPath currently leaks a KeyError when a path contains a token that cannot
start a supported XPath step, such as
@,=, or). Check the token's handlerbefore calling it and raise
SyntaxError("invalid path")when none exists.Keep the C accelerator's literal tag fast path unchanged. This addresses the
exception leak described in the issue without changing which paths the
accelerator delegates to ElementPath.
The regression test covers
find(),findall(),findtext(), anditerfind()on both Element and ElementTree objects. The shared test suite runs it with
both the Python implementation and the C accelerator. Paths starting with
./ensure that the accelerator also delegates these cases to ElementPath.Validation on a locally built Windows x64 debug CPython 3.16.0a2+dev:
PCbuild\amd64\python_d.exe -m test test_xml_etree test_xml_etree_csucceeds: 539 tests, 13 skipped.
AI assistance (Codex) was used to investigate the issue and prepare the patch
and regression test.