Skip to content

Conversation

sergey-miryanov
Copy link
Contributor

@sergey-miryanov sergey-miryanov commented Oct 13, 2025

Following code should decref key and value if PyTuple_New fails:

cpython/Objects/dictobject.c

Lines 5720 to 5726 in 6481539

else {
result = PyTuple_New(2);
if (result == NULL)
return NULL;
PyTuple_SET_ITEM(result, 0, key);
PyTuple_SET_ITEM(result, 1, value);
}

@sergey-miryanov
Copy link
Contributor Author

I believe this should skip news.
Should be backported to 3.13 and 3.14.

@picnixz
Copy link
Member

picnixz commented Oct 13, 2025

@eendebakpt Couldn't we actually use the PyTuple_FromArray API here? If so, I would suggest fixing the refleak as part of the change (I don't know if we gain something)

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