summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-13 17:15:33 (GMT)
committerGitHub <noreply@github.com>2020-03-13 17:15:33 (GMT)
commitbe79373a78c0d75fc715ab64253c9b757987a848 (patch)
tree9fba5caff3547b80fbfd2b468339458e7d5d0037 /Include
parentff4584caca04cb3da0dbd5b1e9bf67e40adf5312 (diff)
downloadcpython-be79373a78c0d75fc715ab64253c9b757987a848.zip
cpython-be79373a78c0d75fc715ab64253c9b757987a848.tar.gz
cpython-be79373a78c0d75fc715ab64253c9b757987a848.tar.bz2
bpo-39947: Add PyInterpreterState_Get() function (GH-18979)
* Rename _PyInterpreterState_Get() to PyInterpreterState_Get() and move it the limited C API. * Add _PyInterpreterState_Get() alias to PyInterpreterState_Get() for backward compatibility with Python 3.8.
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/pystate.h9
-rw-r--r--Include/pystate.h11
2 files changed, 13 insertions, 7 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index fbb0899..96df0d9 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -139,13 +139,8 @@ struct _ts {
};
-/* Get the current interpreter state.
-
- Issue a fatal error if there no current Python thread state or no current
- interpreter. It cannot return NULL.
-
- The caller must hold the GIL.*/
-PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_Get(void);
+// Alias for backward compatibility with Python 3.8
+#define _PyInterpreterState_Get PyInterpreterState_Get
PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
diff --git a/Include/pystate.h b/Include/pystate.h
index 1cb2305..57dc9e4 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -28,6 +28,17 @@ PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
+/* New in 3.9 */
+/* Get the current interpreter state.
+
+ Issue a fatal error if there no current Python thread state or no current
+ interpreter. It cannot return NULL.
+
+ The caller must hold the GIL. */
+PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Get(void);
+#endif
+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000
/* New in 3.8 */
PyAPI_FUNC(PyObject *) PyInterpreterState_GetDict(PyInterpreterState *);