Skip to content

gh-148801: Fix unbound C recursion in Element.__deepcopy__()#148802

Open
StanFromIreland wants to merge 2 commits intopython:mainfrom
StanFromIreland:Element.__deepcopy__
Open

gh-148801: Fix unbound C recursion in Element.__deepcopy__()#148802
StanFromIreland wants to merge 2 commits intopython:mainfrom
StanFromIreland:Element.__deepcopy__

Conversation

@StanFromIreland
Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland commented Apr 20, 2026

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

I have a style suggestion which you can accept or ignore.

Comment thread Modules/_elementtree.c
tag = deepcopy(st, self->tag, memo);
if (!tag)
if (!tag) {
_Py_LeaveRecursiveCall();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three _Py_LeaveRecursiveCalls can be replaced with goto error (you need also to initialize element with NULL and use Py_XDECREF). Larger diff, but three less lines in the result.

The current style is good too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants