Skip to content

gh-158842: Add Py_SETREF() and Py_XSETREF() to the limited C API - #158843

Open
vstinner wants to merge 3 commits into
python:mainfrom
vstinner:limited_setref
Open

vstinner wants to merge 3 commits into
python:mainfrom
vstinner:limited_setref

Conversation

@vstinner

@vstinner vstinner commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Test these macros with the limited C API in _testlimitedcapi and test_cext.

Move also other tests (refcount, Py_CLEAR, etc.) to _testlimitedcapi.

Test these macros with the limited C API in _testlimitedcapi and
test_cext.

Move also other tests (refcount, Py_CLEAR, etc.) to _testlimitedcapi.
@vstinner

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

@vstinner

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Note: _testlimitedcapi.test_py_setref() checks that Py_SETREF/Py_XSETREF() arguments are only evaluated once.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34945011 | 📁 Comparing e98478b against main (9112dae)

  🔍 Preview build  

2 files changed
± whatsnew/3.16.html
± whatsnew/changelog.html

@encukou

encukou commented Oct 5, 2026

Copy link
Copy Markdown
Member

Could you add them to stable_abi.toml, too?

@picnixz picnixz left a comment

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.

If this only moving code, then this LGTM.

@picnixz

picnixz commented Oct 5, 2026

Copy link
Copy Markdown
Member

Could you add them to stable_abi.toml, too?

Oh right... I totally forgot about that. It's for the docs rendering right?

@vstinner
vstinner requested a review from encukou as a code owner October 5, 2026 14:20
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 5, 2026
@vstinner

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Could you add them to stable_abi.toml, too?

Sure, done. I forgot that we also put macros in stable_abi.toml. I also added Py_CLEAR(). It seems like Py_CLEAR() was added to Python 2.4 (so it's available since limited C API 3.2).

@ngoldbaum

Copy link
Copy Markdown
Contributor

It's for the docs rendering right?

I learned recently that abi3audit uses the toml table as input for a codegen script that generates the abi3audit implementation. I'd also like to use it in PyO3 for static checks. So downstream appreciates it being accurate and updated.

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

Labels

awaiting merge type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants