summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-07-22 19:31:55 (GMT)
committerGitHub <noreply@github.com>2023-07-22 19:31:55 (GMT)
commit22422e9d1a50b4970bc6957a88569618d579c47f (patch)
tree63af9e1bf2bc7d2fe10a6c3cd981d866a38eb2fd
parentf8b7fe2f2647813ae8249675a80e59c117d30fe1 (diff)
downloadcpython-22422e9d1a50b4970bc6957a88569618d579c47f.zip
cpython-22422e9d1a50b4970bc6957a88569618d579c47f.tar.gz
cpython-22422e9d1a50b4970bc6957a88569618d579c47f.tar.bz2
gh-106320: Remove private _PyInterpreterID C API (#107053)
Move the private _PyInterpreterID C API to the internal C API: add a new pycore_interp_id.h header file. Remove Include/interpreteridobject.h and Include/cpython/interpreteridobject.h header files.
-rw-r--r--Include/cpython/interpreteridobject.h11
-rw-r--r--Include/internal/pycore_interp_id.h28
-rw-r--r--Include/interpreteridobject.h17
-rw-r--r--Makefile.pre.in3
-rw-r--r--Modules/_testinternalcapi.c4
-rw-r--r--Modules/_xxinterpchannelsmodule.c2
-rw-r--r--Modules/_xxsubinterpretersmodule.c2
-rw-r--r--Objects/interpreteridobject.c2
-rw-r--r--Objects/object.c4
-rw-r--r--PCbuild/pythoncore.vcxproj3
-rw-r--r--PCbuild/pythoncore.vcxproj.filters9
-rw-r--r--Tools/c-analyzer/cpython/_parser.py1
12 files changed, 40 insertions, 46 deletions
diff --git a/Include/cpython/interpreteridobject.h b/Include/cpython/interpreteridobject.h
deleted file mode 100644
index 5076584..0000000
--- a/Include/cpython/interpreteridobject.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#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/internal/pycore_interp_id.h b/Include/internal/pycore_interp_id.h
new file mode 100644
index 0000000..34c96df
--- /dev/null
+++ b/Include/internal/pycore_interp_id.h
@@ -0,0 +1,28 @@
+/* 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 the _xxsubinterpreters shared extension
+PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
+
+// Export for the _xxsubinterpreters shared extension
+PyAPI_FUNC(PyObject*) _PyInterpreterID_New(int64_t);
+
+// Export for the _xxinterpchannels shared extension
+PyAPI_FUNC(PyObject*) _PyInterpreterState_GetIDObject(PyInterpreterState *);
+
+// Export for the _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
deleted file mode 100644
index 8432632..0000000
--- a/Include/interpreteridobject.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#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 */
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 3725fea..5f1988b 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1631,7 +1631,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/floatobject.h \
$(srcdir)/Include/frameobject.h \
$(srcdir)/Include/import.h \
- $(srcdir)/Include/interpreteridobject.h \
$(srcdir)/Include/intrcheck.h \
$(srcdir)/Include/iterobject.h \
$(srcdir)/Include/listobject.h \
@@ -1701,7 +1700,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/cpython/genobject.h \
$(srcdir)/Include/cpython/import.h \
$(srcdir)/Include/cpython/initconfig.h \
- $(srcdir)/Include/cpython/interpreteridobject.h \
$(srcdir)/Include/cpython/listobject.h \
$(srcdir)/Include/cpython/longintrepr.h \
$(srcdir)/Include/cpython/longobject.h \
@@ -1773,6 +1771,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_import.h \
$(srcdir)/Include/internal/pycore_initconfig.h \
$(srcdir)/Include/internal/pycore_interp.h \
+ $(srcdir)/Include/internal/pycore_interp_id.h \
$(srcdir)/Include/internal/pycore_intrinsics.h \
$(srcdir)/Include/internal/pycore_list.h \
$(srcdir)/Include/internal/pycore_long.h \
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 74c932f..ecc2721 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -11,18 +11,18 @@
#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()
-#include "pycore_compile.h" // _PyCompile_CodeGen, _PyCompile_OptimizeCfg, _PyCompile_Assemble, _PyCompile_CleanDoc
#include "pycore_ceval.h" // _PyEval_AddPendingCall
+#include "pycore_compile.h" // _PyCompile_CodeGen, _PyCompile_OptimizeCfg, _PyCompile_Assemble, _PyCompile_CleanDoc
#include "pycore_fileutils.h" // _Py_normpath
#include "pycore_frame.h" // _PyInterpreterFrame
#include "pycore_gc.h" // PyGC_Head
#include "pycore_hashtable.h" // _Py_hashtable_new()
#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
#include "pycore_interp.h" // _PyInterpreterState_GetConfigCopy()
+#include "pycore_interp_id.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 8247255..bdffdba 100644
--- a/Modules/_xxinterpchannelsmodule.c
+++ b/Modules/_xxinterpchannelsmodule.c
@@ -6,8 +6,8 @@
#endif
#include "Python.h"
-#include "interpreteridobject.h"
#include "pycore_atexit.h" // _Py_AtExit()
+#include "pycore_interp_id.h" // _PyInterpreterState_GetIDObject()
/*
diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
index d2e0593..bf01aaf 100644
--- a/Modules/_xxsubinterpretersmodule.c
+++ b/Modules/_xxsubinterpretersmodule.c
@@ -7,7 +7,7 @@
#include "Python.h"
#include "pycore_interp.h" // _PyInterpreterState_GetMainModule()
-#include "interpreteridobject.h"
+#include "pycore_interp_id.h" // _PyInterpreterState_GetIDObject()
#define MODULE_NAME "_xxsubinterpreters"
diff --git a/Objects/interpreteridobject.c b/Objects/interpreteridobject.c
index 4623910..7a3e245 100644
--- a/Objects/interpreteridobject.c
+++ b/Objects/interpreteridobject.c
@@ -3,7 +3,7 @@
#include "Python.h"
#include "pycore_abstract.h" // _PyIndex_Check()
#include "pycore_interp.h" // _PyInterpreterState_LookUpID()
-#include "interpreteridobject.h"
+#include "pycore_interp_id.h" // _PyInterpreterID_Type
typedef struct interpid {
diff --git a/Objects/object.c b/Objects/object.c
index 3b8839b..93396bf 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -8,16 +8,16 @@
#include "pycore_dict.h" // _PyObject_MakeDictFromInstanceAttributes()
#include "pycore_floatobject.h" // _PyFloat_DebugMallocStats()
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
+#include "pycore_interp_id.h" // _PyInterpreterID_Type
#include "pycore_namespace.h" // _PyNamespace_Type
#include "pycore_object.h" // PyAPI_DATA() _Py_SwappedOp definition
#include "pycore_pyerrors.h" // _PyErr_Occurred()
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_symtable.h" // PySTEntry_Type
-#include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic
#include "pycore_typeobject.h" // _PyBufferWrapper_Type
+#include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic
#include "pycore_unionobject.h" // _PyUnion_Type
-#include "interpreteridobject.h" // _PyInterpreterID_Type
#ifdef Py_LIMITED_API
// Prevent recursive call _Py_IncRef() <=> Py_INCREF()
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index bfe59ac..5ccc895 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -152,7 +152,6 @@
<ClInclude Include="..\Include\cpython\genobject.h" />
<ClInclude Include="..\Include\cpython\import.h" />
<ClInclude Include="..\Include\cpython\initconfig.h" />
- <ClInclude Include="..\Include\cpython\interpreteridobject.h" />
<ClInclude Include="..\Include\cpython\listobject.h" />
<ClInclude Include="..\Include\cpython\longintrepr.h" />
<ClInclude Include="..\Include\cpython\longobject.h" />
@@ -238,6 +237,7 @@
<ClInclude Include="..\Include\internal\pycore_import.h" />
<ClInclude Include="..\Include\internal\pycore_initconfig.h" />
<ClInclude Include="..\Include\internal\pycore_interp.h" />
+ <ClInclude Include="..\Include\internal\pycore_interp_id.h" />
<ClInclude Include="..\Include\internal\pycore_intrinsics.h" />
<ClInclude Include="..\Include\internal\pycore_list.h" />
<ClInclude Include="..\Include\internal\pycore_long.h" />
@@ -281,7 +281,6 @@
<ClInclude Include="..\Include\internal\pycore_unicodeobject_generated.h" />
<ClInclude Include="..\Include\internal\pycore_warnings.h" />
<ClInclude Include="..\Include\internal\pycore_weakref.h" />
- <ClInclude Include="..\Include\interpreteridobject.h" />
<ClInclude Include="..\Include\intrcheck.h" />
<ClInclude Include="..\Include\iterobject.h" />
<ClInclude Include="..\Include\listobject.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 0a8b0c3..54a77f8 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -312,9 +312,6 @@
<ClInclude Include="..\Include\pyhash.h">
<Filter>Include</Filter>
</ClInclude>
- <ClInclude Include="..\Include\interpreteridobject.h">
- <Filter>Include</Filter>
- </ClInclude>
<ClInclude Include="..\Modules\hashtable.h">
<Filter>Modules</Filter>
</ClInclude>
@@ -462,9 +459,6 @@
<ClInclude Include="..\Include\cpython\genobject.h">
<Filter>Include</Filter>
</ClInclude>
- <ClInclude Include="..\Include\cpython\interpreteridobject.h">
- <Filter>Include\cpython</Filter>
- </ClInclude>
<ClInclude Include="..\Include\cpython\pythonrun.h">
<Filter>Include\cpython</Filter>
</ClInclude>
@@ -618,6 +612,9 @@
<ClInclude Include="..\Include\internal\pycore_interp.h">
<Filter>Include\internal</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\internal\pycore_interp_id.h">
+ <Filter>Include\internal</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\internal\pycore_intrinsics.h">
<Filter>Include\cpython</Filter>
</ClInclude>
diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py
index 9bc7285..64ce4cd 100644
--- a/Tools/c-analyzer/cpython/_parser.py
+++ b/Tools/c-analyzer/cpython/_parser.py
@@ -227,7 +227,6 @@ Include/cpython/fileobject.h Py_CPYTHON_FILEOBJECT_H 1
Include/cpython/fileutils.h Py_CPYTHON_FILEUTILS_H 1
Include/cpython/frameobject.h Py_CPYTHON_FRAMEOBJECT_H 1
Include/cpython/import.h Py_CPYTHON_IMPORT_H 1
-Include/cpython/interpreteridobject.h Py_CPYTHON_INTERPRETERIDOBJECT_H 1
Include/cpython/listobject.h Py_CPYTHON_LISTOBJECT_H 1
Include/cpython/methodobject.h Py_CPYTHON_METHODOBJECT_H 1
Include/cpython/object.h Py_CPYTHON_OBJECT_H 1