Skip to content

Commit 22422e9

Browse files
authored
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.
1 parent f8b7fe2 commit 22422e9

File tree

12 files changed

+40
-46
lines changed

12 files changed

+40
-46
lines changed

Include/cpython/interpreteridobject.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

Include/internal/pycore_interp_id.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Interpreter ID Object */
2+
3+
#ifndef Py_INTERNAL_INTERPRETERIDOBJECT_H
4+
#define Py_INTERNAL_INTERPRETERIDOBJECT_H
5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
9+
#ifndef Py_BUILD_CORE
10+
# error "this header requires Py_BUILD_CORE define"
11+
#endif
12+
13+
// Export for the _xxsubinterpreters shared extension
14+
PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
15+
16+
// Export for the _xxsubinterpreters shared extension
17+
PyAPI_FUNC(PyObject*) _PyInterpreterID_New(int64_t);
18+
19+
// Export for the _xxinterpchannels shared extension
20+
PyAPI_FUNC(PyObject*) _PyInterpreterState_GetIDObject(PyInterpreterState *);
21+
22+
// Export for the _testinternalcapi shared extension
23+
PyAPI_FUNC(PyInterpreterState*) _PyInterpreterID_LookUp(PyObject *);
24+
25+
#ifdef __cplusplus
26+
}
27+
#endif
28+
#endif // !Py_INTERNAL_INTERPRETERIDOBJECT_H

Include/interpreteridobject.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

Makefile.pre.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,6 @@ PYTHON_HEADERS= \
16311631
$(srcdir)/Include/floatobject.h \
16321632
$(srcdir)/Include/frameobject.h \
16331633
$(srcdir)/Include/import.h \
1634-
$(srcdir)/Include/interpreteridobject.h \
16351634
$(srcdir)/Include/intrcheck.h \
16361635
$(srcdir)/Include/iterobject.h \
16371636
$(srcdir)/Include/listobject.h \
@@ -1701,7 +1700,6 @@ PYTHON_HEADERS= \
17011700
$(srcdir)/Include/cpython/genobject.h \
17021701
$(srcdir)/Include/cpython/import.h \
17031702
$(srcdir)/Include/cpython/initconfig.h \
1704-
$(srcdir)/Include/cpython/interpreteridobject.h \
17051703
$(srcdir)/Include/cpython/listobject.h \
17061704
$(srcdir)/Include/cpython/longintrepr.h \
17071705
$(srcdir)/Include/cpython/longobject.h \
@@ -1773,6 +1771,7 @@ PYTHON_HEADERS= \
17731771
$(srcdir)/Include/internal/pycore_import.h \
17741772
$(srcdir)/Include/internal/pycore_initconfig.h \
17751773
$(srcdir)/Include/internal/pycore_interp.h \
1774+
$(srcdir)/Include/internal/pycore_interp_id.h \
17761775
$(srcdir)/Include/internal/pycore_intrinsics.h \
17771776
$(srcdir)/Include/internal/pycore_list.h \
17781777
$(srcdir)/Include/internal/pycore_long.h \

Modules/_testinternalcapi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111

1212
#include "Python.h"
1313
#include "frameobject.h"
14-
#include "interpreteridobject.h" // _PyInterpreterID_LookUp()
1514
#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
1615
#include "pycore_bitutils.h" // _Py_bswap32()
1716
#include "pycore_bytesobject.h" // _PyBytes_Find()
18-
#include "pycore_compile.h" // _PyCompile_CodeGen, _PyCompile_OptimizeCfg, _PyCompile_Assemble, _PyCompile_CleanDoc
1917
#include "pycore_ceval.h" // _PyEval_AddPendingCall
18+
#include "pycore_compile.h" // _PyCompile_CodeGen, _PyCompile_OptimizeCfg, _PyCompile_Assemble, _PyCompile_CleanDoc
2019
#include "pycore_fileutils.h" // _Py_normpath
2120
#include "pycore_frame.h" // _PyInterpreterFrame
2221
#include "pycore_gc.h" // PyGC_Head
2322
#include "pycore_hashtable.h" // _Py_hashtable_new()
2423
#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
2524
#include "pycore_interp.h" // _PyInterpreterState_GetConfigCopy()
25+
#include "pycore_interp_id.h" // _PyInterpreterID_LookUp()
2626
#include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal()
2727
#include "pycore_pyerrors.h" // _Py_UTF8_Edit_Cost()
2828
#include "pycore_pystate.h" // _PyThreadState_GET()

Modules/_xxinterpchannelsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#endif
77

88
#include "Python.h"
9-
#include "interpreteridobject.h"
109
#include "pycore_atexit.h" // _Py_AtExit()
10+
#include "pycore_interp_id.h" // _PyInterpreterState_GetIDObject()
1111

1212

1313
/*

Modules/_xxsubinterpretersmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "Python.h"
99
#include "pycore_interp.h" // _PyInterpreterState_GetMainModule()
10-
#include "interpreteridobject.h"
10+
#include "pycore_interp_id.h" // _PyInterpreterState_GetIDObject()
1111

1212

1313
#define MODULE_NAME "_xxsubinterpreters"

Objects/interpreteridobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "Python.h"
44
#include "pycore_abstract.h" // _PyIndex_Check()
55
#include "pycore_interp.h" // _PyInterpreterState_LookUpID()
6-
#include "interpreteridobject.h"
6+
#include "pycore_interp_id.h" // _PyInterpreterID_Type
77

88

99
typedef struct interpid {

Objects/object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
#include "pycore_dict.h" // _PyObject_MakeDictFromInstanceAttributes()
99
#include "pycore_floatobject.h" // _PyFloat_DebugMallocStats()
1010
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
11+
#include "pycore_interp_id.h" // _PyInterpreterID_Type
1112
#include "pycore_namespace.h" // _PyNamespace_Type
1213
#include "pycore_object.h" // PyAPI_DATA() _Py_SwappedOp definition
1314
#include "pycore_pyerrors.h" // _PyErr_Occurred()
1415
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
1516
#include "pycore_pystate.h" // _PyThreadState_GET()
1617
#include "pycore_symtable.h" // PySTEntry_Type
17-
#include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic
1818
#include "pycore_typeobject.h" // _PyBufferWrapper_Type
19+
#include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic
1920
#include "pycore_unionobject.h" // _PyUnion_Type
20-
#include "interpreteridobject.h" // _PyInterpreterID_Type
2121

2222
#ifdef Py_LIMITED_API
2323
// Prevent recursive call _Py_IncRef() <=> Py_INCREF()

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@
152152
<ClInclude Include="..\Include\cpython\genobject.h" />
153153
<ClInclude Include="..\Include\cpython\import.h" />
154154
<ClInclude Include="..\Include\cpython\initconfig.h" />
155-
<ClInclude Include="..\Include\cpython\interpreteridobject.h" />
156155
<ClInclude Include="..\Include\cpython\listobject.h" />
157156
<ClInclude Include="..\Include\cpython\longintrepr.h" />
158157
<ClInclude Include="..\Include\cpython\longobject.h" />
@@ -238,6 +237,7 @@
238237
<ClInclude Include="..\Include\internal\pycore_import.h" />
239238
<ClInclude Include="..\Include\internal\pycore_initconfig.h" />
240239
<ClInclude Include="..\Include\internal\pycore_interp.h" />
240+
<ClInclude Include="..\Include\internal\pycore_interp_id.h" />
241241
<ClInclude Include="..\Include\internal\pycore_intrinsics.h" />
242242
<ClInclude Include="..\Include\internal\pycore_list.h" />
243243
<ClInclude Include="..\Include\internal\pycore_long.h" />
@@ -281,7 +281,6 @@
281281
<ClInclude Include="..\Include\internal\pycore_unicodeobject_generated.h" />
282282
<ClInclude Include="..\Include\internal\pycore_warnings.h" />
283283
<ClInclude Include="..\Include\internal\pycore_weakref.h" />
284-
<ClInclude Include="..\Include\interpreteridobject.h" />
285284
<ClInclude Include="..\Include\intrcheck.h" />
286285
<ClInclude Include="..\Include\iterobject.h" />
287286
<ClInclude Include="..\Include\listobject.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@
312312
<ClInclude Include="..\Include\pyhash.h">
313313
<Filter>Include</Filter>
314314
</ClInclude>
315-
<ClInclude Include="..\Include\interpreteridobject.h">
316-
<Filter>Include</Filter>
317-
</ClInclude>
318315
<ClInclude Include="..\Modules\hashtable.h">
319316
<Filter>Modules</Filter>
320317
</ClInclude>
@@ -462,9 +459,6 @@
462459
<ClInclude Include="..\Include\cpython\genobject.h">
463460
<Filter>Include</Filter>
464461
</ClInclude>
465-
<ClInclude Include="..\Include\cpython\interpreteridobject.h">
466-
<Filter>Include\cpython</Filter>
467-
</ClInclude>
468462
<ClInclude Include="..\Include\cpython\pythonrun.h">
469463
<Filter>Include\cpython</Filter>
470464
</ClInclude>
@@ -618,6 +612,9 @@
618612
<ClInclude Include="..\Include\internal\pycore_interp.h">
619613
<Filter>Include\internal</Filter>
620614
</ClInclude>
615+
<ClInclude Include="..\Include\internal\pycore_interp_id.h">
616+
<Filter>Include\internal</Filter>
617+
</ClInclude>
621618
<ClInclude Include="..\Include\internal\pycore_intrinsics.h">
622619
<Filter>Include\cpython</Filter>
623620
</ClInclude>

Tools/c-analyzer/cpython/_parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ def clean_lines(text):
227227
Include/cpython/fileutils.h Py_CPYTHON_FILEUTILS_H 1
228228
Include/cpython/frameobject.h Py_CPYTHON_FRAMEOBJECT_H 1
229229
Include/cpython/import.h Py_CPYTHON_IMPORT_H 1
230-
Include/cpython/interpreteridobject.h Py_CPYTHON_INTERPRETERIDOBJECT_H 1
231230
Include/cpython/listobject.h Py_CPYTHON_LISTOBJECT_H 1
232231
Include/cpython/methodobject.h Py_CPYTHON_METHODOBJECT_H 1
233232
Include/cpython/object.h Py_CPYTHON_OBJECT_H 1

0 commit comments

Comments
 (0)