summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-07-27 19:15:47 (GMT)
committerGitHub <noreply@github.com>2023-07-27 19:15:47 (GMT)
commit57ef065eb3a9200aece38dfb6b90055500f076d3 (patch)
tree0f7533f86d5a3750f70deebf66609b13b0d9634f /Modules
parent0063ad8189cd4ac84775eb9150b7f3373842568a (diff)
downloadcpython-57ef065eb3a9200aece38dfb6b90055500f076d3.zip
cpython-57ef065eb3a9200aece38dfb6b90055500f076d3.tar.gz
cpython-57ef065eb3a9200aece38dfb6b90055500f076d3.tar.bz2
[3.12] gh-101524: Only Use Public C-API in the _xxsubinterpreters Module (gh-105258) (gh-107303)
The _xxsubinterpreters module was meant to only use public API. Some internal C-API usage snuck in over the last few years (e.g. gh-28969). This fixes that. (cherry picked from commit e6373c0d8b59512aa7f0dea7f3fb162b6ed10fa4) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testinternalcapi.c2
-rw-r--r--Modules/_xxinterpchannelsmodule.c6
-rw-r--r--Modules/_xxsubinterpretersmodule.c12
3 files changed, 5 insertions, 15 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 6fc31f6..4e063a8 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -13,6 +13,7 @@
#include "Python.h"
#include "frameobject.h"
+#include "interpreteridobject.h" // _PyInterpreterID_LookUp()
#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
#include "pycore_bitutils.h" // _Py_bswap32()
#include "pycore_bytesobject.h" // _PyBytes_Find()
@@ -24,7 +25,6 @@
#include "pycore_hashtable.h" // _Py_hashtable_new()
#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
#include "pycore_interp.h" // _PyInterpreterState_GetConfigCopy()
-#include "pycore_interpreteridobject.h" // _PyInterpreterID_LookUp()
#include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal()
#include "pycore_pyerrors.h" // _Py_UTF8_Edit_Cost()
#include "pycore_pystate.h" // _PyThreadState_GET()
diff --git a/Modules/_xxinterpchannelsmodule.c b/Modules/_xxinterpchannelsmodule.c
index 616dd57..1d7e7f1 100644
--- a/Modules/_xxinterpchannelsmodule.c
+++ b/Modules/_xxinterpchannelsmodule.c
@@ -1,13 +1,9 @@
/* interpreters module */
/* low-level access to interpreter primitives */
-#ifndef Py_BUILD_CORE_BUILTIN
-# define Py_BUILD_CORE_MODULE 1
-#endif
#include "Python.h"
-#include "pycore_pystate.h" // _PyThreadState_GET()
-#include "pycore_interpreteridobject.h"
+#include "interpreteridobject.h"
/*
diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
index d7daae2..4801f37 100644
--- a/Modules/_xxsubinterpretersmodule.c
+++ b/Modules/_xxsubinterpretersmodule.c
@@ -1,15 +1,9 @@
/* interpreters module */
/* low-level access to interpreter primitives */
-#ifndef Py_BUILD_CORE_BUILTIN
-# define Py_BUILD_CORE_MODULE 1
-#endif
#include "Python.h"
-// XXX This module should not rely on internal API.
-#include "pycore_frame.h"
-#include "pycore_pystate.h" // _PyThreadState_GET()
-#include "pycore_interpreteridobject.h"
+#include "interpreteridobject.h"
#define MODULE_NAME "_xxsubinterpreters"
@@ -376,7 +370,7 @@ _is_running(PyInterpreterState *interp)
}
assert(!PyErr_Occurred());
- _PyInterpreterFrame *frame = tstate->cframe->current_frame;
+ struct _PyInterpreterFrame *frame = tstate->cframe->current_frame;
if (frame == NULL) {
return 0;
}
@@ -512,7 +506,7 @@ interp_create(PyObject *self, PyObject *args, PyObject *kwds)
}
// Create and initialize the new interpreter.
- PyThreadState *save_tstate = _PyThreadState_GET();
+ PyThreadState *save_tstate = PyThreadState_Get();
assert(save_tstate != NULL);
const PyInterpreterConfig config = isolated
? (PyInterpreterConfig)_PyInterpreterConfig_INIT