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

Add PyUnstable_SetImmortal by kumaraditya303 · Pull Request #164 · python/pythoncapi-compat · GitHub

Add PyUnstable_SetImmortal - #164

Merged
vstinner merged 8 commits into
python:mainfrom
kumaraditya303:main
Feb 12, 2026
Merged

Add PyUnstable_SetImmortal#164
vstinner merged 8 commits into
python:mainfrom
kumaraditya303:main

Conversation

Copy link
Copy Markdown
Contributor

No description provided.

vstinner 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

Please document the new function in docs/changelog.rst and docs/api.rst.

Comment thread tests/test_pythoncapi_compat_cext.c Outdated
kumaraditya303 marked this pull request as ready for review February 12, 2026 12:32
Comment thread docs/api.rst
Comment thread pythoncapi_compat.h Outdated
kumaraditya303 and others added 2 commits February 12, 2026 18:11
Co-authored-by: Victor Stinner <vstinner@python.org>
Comment thread pythoncapi_compat.h

vstinner 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

I agree to not add Python 3.12 support.

It's tempting to add Python 3.12 support, but Python 3.12 semantics is different:

static inline void _Py_SetImmortal(PyObject *op)
{
    if (op) {
        op->ob_refcnt = _Py_IMMORTAL_REFCNT;
    }
}
  • Different API: it has no return value (void)!
  • It doesn't reject Unicode objects.
  • It doesn't untrack objects in the GC.
// Immortal objects were implemented in Python 3.12, however there is no easy API
// to make objects immortal until 3.14 which has _Py_SetImmortal(). Since
// immortal objects are primarily needed for free-threading, this API is implemented
// for 3.14 using _Py_SetImmortal() and uses private macros on 3.13.

I agree that PyUnstable_SetImmortal() is mostly useful on free-threaded builds, so it's ok to skip Python 3.12.

vstinner 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

LGTM.

Copy link
Copy Markdown
Member

Good, the tests passed successfully on Python 3.13 on regular build and free-threaded build:

  • Build / build (macos-latest, 3.13) (pull_request)
  • Build / build (macos-latest, 3.13t) (pull_request)

vstinner merged commit 8636bcc into python:main Feb 12, 2026
36 checks passed
Comment thread pythoncapi_compat.h
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL