summaryrefslogtreecommitdiffstats
path: root/Objects/genobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-01 00:51:40 (GMT)
committerGitHub <noreply@github.com>2018-11-01 00:51:40 (GMT)
commit50b48572d9a90c5bb36e2bef6179548ea927a35a (patch)
tree3b77efe6c7182a3e0b98fcba9854198dbeca3a98 /Objects/genobject.c
parent27e2d1f21975dfb8c0ddcb192fa0f45a51b7977e (diff)
downloadcpython-50b48572d9a90c5bb36e2bef6179548ea927a35a.zip
cpython-50b48572d9a90c5bb36e2bef6179548ea927a35a.tar.gz
cpython-50b48572d9a90c5bb36e2bef6179548ea927a35a.tar.bz2
bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)
If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access _PyRuntime which comes from the internal pycore_state.h header. Public headers must not require internal headers. Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from Include/pystate.h to Include/internal/pycore_state.h, and rename PyThreadState_GET() to _PyThreadState_GET() there. The PyThreadState_GET() macro of pystate.h is now redefined when pycore_state.h is included, to use the fast _PyThreadState_GET(). Changes: * Add _PyThreadState_GET() macro * Replace "PyThreadState_GET()->interp" with _PyInterpreterState_GET_UNSAFE() * Replace PyThreadState_GET() with _PyThreadState_GET() in internal C files (compiled with Py_BUILD_CORE defined), but keep PyThreadState_GET() in the public header files. * _testcapimodule.c: replace PyThreadState_GET() with PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE defined. * pycore_state.h now requires Py_BUILD_CORE to be defined.
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r--Objects/genobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 885b3f2..7c2948b 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -151,7 +151,7 @@ gen_dealloc(PyGenObject *gen)
static PyObject *
gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing)
{
- PyThreadState *tstate = PyThreadState_GET();
+ PyThreadState *tstate = _PyThreadState_GET();
PyFrameObject *f = gen->gi_frame;
PyObject *result;
@@ -1157,7 +1157,7 @@ PyCoro_New(PyFrameObject *f, PyObject *name, PyObject *qualname)
return NULL;
}
- PyThreadState *tstate = PyThreadState_GET();
+ PyThreadState *tstate = _PyThreadState_GET();
int origin_depth = tstate->coroutine_origin_tracking_depth;
if (origin_depth == 0) {
@@ -1267,7 +1267,7 @@ async_gen_init_hooks(PyAsyncGenObject *o)
o->ag_hooks_inited = 1;
- tstate = PyThreadState_GET();
+ tstate = _PyThreadState_GET();
finalizer = tstate->async_gen_finalizer;
if (finalizer) {