summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-01-20 10:12:38 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-01-20 10:12:38 (GMT)
commitbfd316e750bc3040c08d1b5872e2de188e8c1e5f (patch)
treea0f5fc0ce8c171cd2b1f875c33b6089471c07447 /Include
parentaebb6d3682e08c93d8468a9291180c5cbdc2df1b (diff)
downloadcpython-bfd316e750bc3040c08d1b5872e2de188e8c1e5f.zip
cpython-bfd316e750bc3040c08d1b5872e2de188e8c1e5f.tar.gz
cpython-bfd316e750bc3040c08d1b5872e2de188e8c1e5f.tar.bz2
Add _PyThreadState_UncheckedGet()
Issue #26154: Add a new private _PyThreadState_UncheckedGet() function which gets the current thread state, but don't call Py_FatalError() if it is NULL. Python 3.5.1 removed the _PyThreadState_Current symbol from the Python C API to no more expose complex and private atomic types. Atomic types depends on the compiler or can even depend on compiler options. The new function _PyThreadState_UncheckedGet() allows to get the variable value without having to care of the exact implementation of atomic types. Changes: * Replace direct usage of the _PyThreadState_Current variable with a call to _PyThreadState_UncheckedGet(). * In pystate.c, replace direct usage of the _PyThreadState_Current variable with the PyThreadState_GET() macro for readability. * Document also PyThreadState_Get() in pystate.h
Diffstat (limited to 'Include')
-rw-r--r--Include/pystate.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/Include/pystate.h b/Include/pystate.h
index 6000b81..b50b16b 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -168,7 +168,17 @@ PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
PyAPI_FUNC(void) _PyGILState_Reinit(void);
#endif
+/* Return the current thread state. The global interpreter lock must be held.
+ * When the current thread state is NULL, this issues a fatal error (so that
+ * the caller needn't check for NULL). */
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
+
+#ifdef WITH_THREAD
+/* Similar to PyThreadState_Get(), but don't issue a fatal error
+ * if it is NULL. */
+PyAPI_FUNC(PyThreadState *) _PyThreadState_UncheckedGet(void);
+#endif
+
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);