Skip to content

[3.15] gh-159739: Handle pyexpat configuration changes during callbacks (GH-160399) - #160475

Merged
JelleZijlstra merged 1 commit into
python:3.15from
miss-islington:backport-0ba58e7-3.15
Oct 24, 2026
Merged

JelleZijlstra merged 1 commit into
python:3.15from
miss-islington:backport-0ba58e7-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

A character data callback can disable buffering or remove the next event handler during a flush. Interning an attribute name can also change ordered_attributes while pyexpat is filling the attribute container. Using the freed buffer, cleared handler, or wrong container type can crash the interpreter. Clear the buffered length before dispatch, keep the active handler alive, recheck the buffer and handlers after callbacks, and use one attribute mode for the whole start event.
(cherry picked from commit 0ba58e7)

Co-authored-by: Jelle Zijlstra jelle@openai.com

pythonGH-160399)

A character data callback can disable buffering or remove the next event handler during a flush. Interning an attribute name can also change ordered_attributes while pyexpat is filling the attribute container. Using the freed buffer, cleared handler, or wrong container type can crash the interpreter. Clear the buffered length before dispatch, keep the active handler alive, recheck the buffer and handlers after callbacks, and use one attribute mode for the whole start event.
(cherry picked from commit 0ba58e7)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
@JelleZijlstra
JelleZijlstra merged commit 0ab39af into python:3.15 Oct 24, 2026
59 checks passed
@miss-islington
miss-islington deleted the backport-0ba58e7-3.15 branch October 24, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants