Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Py_IsFinalizing()#66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 1 commit intomainfromis_finalizing
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletionsdocs/api.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,6 +67,15 @@ Python 3.13
See `PyWeakref_GetRef() documentation<https://docs.python.org/dev/c-api/weakref.html#c.PyWeakref_GetRef>`__.
..c:function::intPy_IsFinalizing()
Return non-zero if the Python interpreter is shutting down, return 0
otherwise.
Availability: Python 3.3 and newer, PyPy 7.3 and newer.
See `Py_IsFinalizing() documentation <https://docs.python.org/dev/c-api/init.html#c.Py_IsFinalizing>`__.
Python 3.12
-----------
Expand Down
1 change: 1 addition & 0 deletionsdocs/changelog.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
Changelog
=========

* 2023-08-16: Add ``Py_IsFinalizing()`` function.
* 2023-07-21: Add ``PyDict_GetItemRef()`` function.
* 2023-07-18: Add ``PyModule_Add()`` function.
* 2023-07-12: Add ``PyObject_GetOptionalAttr()``,
Expand Down
18 changes: 18 additions & 0 deletionspythoncapi_compat.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -846,6 +846,24 @@ PyModule_Add(PyObject *mod, const char *name, PyObject *value)
#endif


// gh-108014 added Py_IsFinalizing() to Python 3.13.0a1
// bpo-1856 added _Py_Finalizing to Python 3.2.1b1.
// Py_IsFinalizing() was added to PyPy 7.3.0.
#if (0x030201B1 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030D00A1) \
&& (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM >= 0x7030000)
PYCAPI_COMPAT_STATIC_INLINE(int)
Py_IsFinalizing(void)
{
#if PY_VERSION_HEX >= 0x030700A1
// _Py_IsFinalizing() was added to Python 3.7.0a1.
return _Py_IsFinalizing();
#else
return (_Py_Finalizing != NULL);
#endif
}
#endif


#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 5 additions & 0 deletionstests/test_pythoncapi_compat_cext.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -328,6 +328,11 @@ test_interpreter(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
PyInterpreterState *interp2 = PyThreadState_GetInterpreter(tstate);
assert(interp == interp2);

#if 0x030300A1 <= PY_VERSION_HEX && (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM >= 0x7030000)
// test Py_IsFinalizing()
assert(Py_IsFinalizing() == 0);
#endif

Py_RETURN_NONE;
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp