FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-158842: Add Py_SETREF() and Py_XSETREF() to the limited C API by vstinner · Pull Request #158843 · python/cpython · GitHub

Repository navigation

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

Merged
vstinner merged 4 commits into
python:mainfrom
vstinner:limited_setref
Oct 6, 2026
Merged

vstinner merged 4 commits into
python:mainfrom
vstinner:limited_setref

Conversation

vstinner commented Oct 5, 2026 •
edited by bedevere-app Bot
Loading

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 commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

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 Bot commented Oct 5, 2026 •
edited
Loading

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34952784 | 📁 Comparing 7ce90fe against main (9112dae)

  🔍 Preview build  

4 files changed
± c-api/refcounting.html
± c-api/stable.html
± whatsnew/3.16.html
± whatsnew/changelog.html

encukou commented Oct 5, 2026

Copy link
Copy Markdown
Member

Could you add them to stable_abi.toml, too?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If this only moving code, then this LGTM.

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 requested a review from encukou as a code owner October 5, 2026 14:20
bedevere-app Bot added the type-feature A feature request or enhancement label Oct 5, 2026

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

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.

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

@encukou: Oh, Doc/c-api/refcounting.rst has .. c:function:: void Py_CLEAR(PyObject *o) whereas Misc/stable_abi.toml has [macro.Py_CLEAR].

It makes Sphinx grumpy because it's once documented as a function, and then documented as a macro... Should I change the documentation to document Py_CLEAR() as a macro?

Sphinx error:

sphinx.errors.SphinxParallelError: sphinx.errors.ExtensionError: Handler <function add_annotations at 0x7172f4a81fd0> for event 'doctree-read' threw an exception (exception: Object type mismatch in limited API annotation for Py_CLEAR: 'macro' != 'function')

encukou commented Oct 5, 2026 via email

Copy link
Copy Markdown
Member

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Maybe leave the existing ones to a different PR. As docs fixes, they're backportable.

I created issue #158886 and PR #158887 to add all old macros of the limited C API to Misc/stable_abi.toml, not only Py_CLEAR() :-)

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Check labels / Unresolved review (pull_request): Cancelled after 15m

I'm not sure why this job took 15 minutes. It seems like something went wrong. I clicked on re-run failed jobs.

vstinner merged commit ec14f81 into python:main Oct 6, 2026
101 of 104 checks passed
vstinner deleted the limited_setref branch October 6, 2026 19:13

vstinner commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

Merged. Thanks for reviews!

encukou commented Oct 7, 2026

Copy link
Copy Markdown
Member

Thank you!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL