summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.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 /Python/sysmodule.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 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index cb13e21..830f0a8 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -336,7 +336,7 @@ PyDoc_STRVAR(excepthook_doc,
static PyObject *
sys_exc_info(PyObject *self, PyObject *noargs)
{
- _PyErr_StackItem *err_info = _PyErr_GetTopmostException(PyThreadState_GET());
+ _PyErr_StackItem *err_info = _PyErr_GetTopmostException(_PyThreadState_GET());
return Py_BuildValue(
"(OOO)",
err_info->exc_type != NULL ? err_info->exc_type : Py_None,
@@ -565,7 +565,7 @@ function call. See the debugger chapter in the library manual."
static PyObject *
sys_gettrace(PyObject *self, PyObject *args)
{
- PyThreadState *tstate = PyThreadState_GET();
+ PyThreadState *tstate = _PyThreadState_GET();
PyObject *temp = tstate->c_traceobj;
if (temp == NULL)
@@ -603,7 +603,7 @@ and return. See the profiler chapter in the library manual."
static PyObject *
sys_getprofile(PyObject *self, PyObject *args)
{
- PyThreadState *tstate = PyThreadState_GET();
+ PyThreadState *tstate = _PyThreadState_GET();
PyObject *temp = tstate->c_profileobj;
if (temp == NULL)
@@ -722,7 +722,7 @@ sys_setrecursionlimit(PyObject *self, PyObject *args)
the new low-water mark. Otherwise it may not be possible anymore to
reset the overflowed flag to 0. */
mark = _Py_RecursionLimitLowerWaterMark(new_limit);
- tstate = PyThreadState_GET();
+ tstate = _PyThreadState_GET();
if (tstate->recursion_depth >= mark) {
PyErr_Format(PyExc_RecursionError,
"cannot set the recursion limit to %i at "
@@ -1362,7 +1362,7 @@ purposes only."
static PyObject *
sys_getframe(PyObject *self, PyObject *args)
{
- PyFrameObject *f = PyThreadState_GET()->frame;
+ PyFrameObject *f = _PyThreadState_GET()->frame;
int depth = -1;
if (!PyArg_ParseTuple(args, "|i:_getframe", &depth))
@@ -1745,7 +1745,7 @@ static int
_PySys_ReadPreInitOptions(void)
{
/* Rerun the add commands with the actual sys module available */
- PyThreadState *tstate = PyThreadState_GET();
+ PyThreadState *tstate = _PyThreadState_GET();
if (tstate == NULL) {
/* Still don't have a thread state, so something is wrong! */
return -1;
@@ -1796,7 +1796,7 @@ get_warnoptions(void)
void
PySys_ResetWarnOptions(void)
{
- PyThreadState *tstate = PyThreadState_GET();
+ PyThreadState *tstate = _PyThreadState_GET();
if (tstate == NULL) {
_clear_preinit_entries(&_preinit_warnoptions);
return;
@@ -1835,7 +1835,7 @@ PySys_AddWarnOptionUnicode(PyObject *option)
void
PySys_AddWarnOption(const wchar_t *s)
{
- PyThreadState *tstate = PyThreadState_GET();
+ PyThreadState *tstate = _PyThreadState_GET();
if (tstate == NULL) {
_append_preinit_entry(&_preinit_warnoptions, s);
return;
@@ -1922,7 +1922,7 @@ error:
void
PySys_AddXOption(const wchar_t *s)
{
- PyThreadState *tstate = PyThreadState_GET();
+ PyThreadState *tstate = _PyThreadState_GET();
if (tstate == NULL) {
_append_preinit_entry(&_preinit_xoptions, s);
return;