Skip to content

GH-145247: Use _PyTuple_FromPair[Steal] in Objects#145884

Open
sergey-miryanov wants to merge 5 commits intopython:mainfrom
sergey-miryanov:feat/145247-pytuple-from-pair-use-2
Open

GH-145247: Use _PyTuple_FromPair[Steal] in Objects#145884
sergey-miryanov wants to merge 5 commits intopython:mainfrom
sergey-miryanov:feat/145247-pytuple-from-pair-use-2

Conversation

@sergey-miryanov
Copy link
Contributor

@sergey-miryanov sergey-miryanov commented Mar 12, 2026

It is a second PR for usage of _PyTuple_FromPair[Steal] in the codebase.

result = _PyTuple_FromPairSteal(is_attr_obj, obj);
return result;

done:
Copy link
Member

Choose a reason for hiding this comment

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

change done to error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

result = _PyTuple_FromPairSteal(first_obj, (PyObject *)it);
return result;

done:
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

to_delete = PyObject_RichCompareBool(val1, val2, Py_EQ);
Py_DECREF(val1);
if (to_delete < 0) {
goto error;
Copy link
Member

Choose a reason for hiding this comment

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

Is this safe? If goto error happens, won't it decref twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, it is not safe. I don't understand why I did this (blame on me).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -1439,7 +1439,7 @@ list_extend_dictitems(PyListObject *self, PyDictObject *dict)
Py_ssize_t i = 0;
PyObject *key_value[2];
Copy link
Member

Choose a reason for hiding this comment

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

change this to key, value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor Author

@sergey-miryanov sergey-miryanov left a comment

Choose a reason for hiding this comment

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

Address review

result = _PyTuple_FromPairSteal(is_attr_obj, obj);
return result;

done:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

result = _PyTuple_FromPairSteal(first_obj, (PyObject *)it);
return result;

done:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -1439,7 +1439,7 @@ list_extend_dictitems(PyListObject *self, PyDictObject *dict)
Py_ssize_t i = 0;
PyObject *key_value[2];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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