]> granicus.if.org Git - python/commit
bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)
authorVictor Stinner <vstinner@redhat.com>
Thu, 1 Nov 2018 00:51:40 +0000 (01:51 +0100)
committerGitHub <noreply@github.com>
Thu, 1 Nov 2018 00:51:40 +0000 (01:51 +0100)
commit50b48572d9a90c5bb36e2bef6179548ea927a35a
tree3b77efe6c7182a3e0b98fcba9854198dbeca3a98
parent27e2d1f21975dfb8c0ddcb192fa0f45a51b7977e
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.
20 files changed:
Include/internal/pycore_state.h
Include/pystate.h
Modules/_testcapimodule.c
Objects/call.c
Objects/dictobject.c
Objects/genobject.c
Objects/object.c
Objects/odictobject.c
Objects/typeobject.c
Parser/myreadline.c
Python/_warnings.c
Python/ceval.c
Python/context.c
Python/errors.c
Python/pylifecycle.c
Python/pystate.c
Python/symtable.c
Python/sysmodule.c
Python/thread_nt.h
Python/thread_pthread.h