summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-07-27 21:30:16 (GMT)
committerGitHub <noreply@github.com>2023-07-27 21:30:16 (GMT)
commit8bdae1424b54e5106782f2b9e2fadce444dc84cd (patch)
tree46aaf156abbf2f6a28235a824009365f4c53dd96 /Include
parent75c974f5353685f338344618ad7344e64c2293d0 (diff)
downloadcpython-8bdae1424b54e5106782f2b9e2fadce444dc84cd.zip
cpython-8bdae1424b54e5106782f2b9e2fadce444dc84cd.tar.gz
cpython-8bdae1424b54e5106782f2b9e2fadce444dc84cd.tar.bz2
gh-101524: Only Use Public C-API in the _xxsubinterpreters Module (gh-107359)
The _xxsubinterpreters module should not rely on internal API. Some of the functions it uses were recently moved there however. Here we move them back (and expose them properly).
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/interpreteridobject.h11
-rw-r--r--Include/cpython/pylifecycle.h4
-rw-r--r--Include/cpython/pystate.h1
-rw-r--r--Include/internal/pycore_interp.h3
-rw-r--r--Include/internal/pycore_interp_id.h28
-rw-r--r--Include/interpreteridobject.h17
6 files changed, 33 insertions, 31 deletions
diff --git a/Include/cpython/interpreteridobject.h b/Include/cpython/interpreteridobject.h
new file mode 100644
index 0000000..4ab9ad5
--- /dev/null
+++ b/Include/cpython/interpreteridobject.h
@@ -0,0 +1,11 @@
+#ifndef Py_CPYTHON_INTERPRETERIDOBJECT_H
+# error "this header file must not be included directly"
+#endif
+
+/* Interpreter ID Object */
+
+PyAPI_DATA(PyTypeObject) PyInterpreterID_Type;
+
+PyAPI_FUNC(PyObject *) PyInterpreterID_New(int64_t);
+PyAPI_FUNC(PyObject *) PyInterpreterState_GetIDObject(PyInterpreterState *);
+PyAPI_FUNC(PyInterpreterState *) PyInterpreterID_LookUp(PyObject *);
diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/pylifecycle.h
index a78cec9..d425a23 100644
--- a/Include/cpython/pylifecycle.h
+++ b/Include/cpython/pylifecycle.h
@@ -77,3 +77,7 @@ typedef struct {
PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
PyThreadState **tstate_p,
const PyInterpreterConfig *config);
+
+typedef void (*atexit_datacallbackfunc)(void *);
+PyAPI_FUNC(int) PyUnstable_AtExit(
+ PyInterpreterState *, atexit_datacallbackfunc, void *);
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 4254110..30de4ee 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -8,6 +8,7 @@
PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int);
+PyAPI_FUNC(PyObject *) PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *);
/* State unique per thread */
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 522ce4a..bd6a9f2 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -238,9 +238,6 @@ extern int _PyInterpreterState_IDInitref(PyInterpreterState *);
extern int _PyInterpreterState_IDIncref(PyInterpreterState *);
extern void _PyInterpreterState_IDDecref(PyInterpreterState *);
-// Export for '_xxsubinterpreters' shared extension
-PyAPI_FUNC(PyObject*) _PyInterpreterState_GetMainModule(PyInterpreterState *);
-
extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp);
/* Get a copy of the current interpreter configuration.
diff --git a/Include/internal/pycore_interp_id.h b/Include/internal/pycore_interp_id.h
deleted file mode 100644
index 8c6f831..0000000
--- a/Include/internal/pycore_interp_id.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Interpreter ID Object */
-
-#ifndef Py_INTERNAL_INTERPRETERIDOBJECT_H
-#define Py_INTERNAL_INTERPRETERIDOBJECT_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef Py_BUILD_CORE
-# error "this header requires Py_BUILD_CORE define"
-#endif
-
-// Export for '_xxsubinterpreters' shared extension
-PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
-
-// Export for '_xxsubinterpreters' shared extension
-PyAPI_FUNC(PyObject*) _PyInterpreterID_New(int64_t);
-
-// Export for '_xxinterpchannels' shared extension
-PyAPI_FUNC(PyObject*) _PyInterpreterState_GetIDObject(PyInterpreterState *);
-
-// Export for '_testinternalcapi' shared extension
-PyAPI_FUNC(PyInterpreterState*) _PyInterpreterID_LookUp(PyObject *);
-
-#ifdef __cplusplus
-}
-#endif
-#endif // !Py_INTERNAL_INTERPRETERIDOBJECT_H
diff --git a/Include/interpreteridobject.h b/Include/interpreteridobject.h
new file mode 100644
index 0000000..8432632
--- /dev/null
+++ b/Include/interpreteridobject.h
@@ -0,0 +1,17 @@
+#ifndef Py_INTERPRETERIDOBJECT_H
+#define Py_INTERPRETERIDOBJECT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_LIMITED_API
+# define Py_CPYTHON_INTERPRETERIDOBJECT_H
+# include "cpython/interpreteridobject.h"
+# undef Py_CPYTHON_INTERPRETERIDOBJECT_H
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERPRETERIDOBJECT_H */