Skip to content

Conversation

@efimov-mikhail
Copy link
Member

@efimov-mikhail efimov-mikhail commented Oct 7, 2025

New test file Lib/test/test_stackrefs.py introduced.
Some auxillary functions are added to _testinternalcapi.
Those functions are examples of correct StackRef scenarios.
We check that all refcounts remain correct.
And that results are the same for equivalent scenarios.

@efimov-mikhail
Copy link
Member Author

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

Looks good. I've one concern about code organization, but that's all.

@bedevere-app
Copy link

bedevere-app bot commented Oct 27, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@efimov-mikhail
Copy link
Member Author

I have made the requested changes; please review again.

@bedevere-app
Copy link

bedevere-app bot commented Oct 27, 2025

Thanks for making the requested changes!

@markshannon: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested a review from markshannon October 27, 2025 16:24
@efimov-mikhail efimov-mikhail marked this pull request as draft October 27, 2025 19:05
@efimov-mikhail efimov-mikhail marked this pull request as ready for review October 27, 2025 19:05
@efimov-mikhail
Copy link
Member Author

Failure was because of #131229

@efimov-mikhail
Copy link
Member Author

Friendly ping, @markshannon @Fidget-Spinner .
Maybe I should make another change to this PR?

Copy link
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

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

Just two questions

_PyStackRef_AsTuple(_PyStackRef ref, PyObject *op)
{
// Do not check StackRef flags in the free threading build.
return Py_BuildValue("(ni)", Py_REFCNT(op), -1);
Copy link
Member Author

@efimov-mikhail efimov-mikhail Nov 17, 2025

Choose a reason for hiding this comment

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

Actually, I've realized that we could remove this special case.
It's related only to stackrefs for immortal objects at ft build.

We can make a little change for _PyStackRef_FromPyObjectSteal and for PyStackRef_FromPyObjectNew function: add Py_TAG_DEFERRED flag to references on immortal objects.
All tests passed with this change on my machine.
But I suggest doing this in the next small PR, and keep only tests changes here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've created a #141675 for this change.

Copy link
Contributor

@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.

Thanks!

@efimov-mikhail
Copy link
Member Author

CC @markshannon @Fidget-Spinner @colesbury
Could we merge this?

Another option is merge #143024 first and adapt tests for that change here.

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

Labels

awaiting review skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants