Skip to content

Commit a801680

Browse files
Revert "pythongh-106320: Remove private _PyInterpreterID C API (python#107053)"
This reverts commit 22422e9.
1 parent 40f4d3d commit a801680

File tree

12 files changed

+48
-42
lines changed

12 files changed

+48
-42
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef Py_CPYTHON_INTERPRETERIDOBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
/* Interpreter ID Object */
6+
7+
PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
8+
9+
PyAPI_FUNC(PyObject *) _PyInterpreterID_New(int64_t);
10+
PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
11+
PyAPI_FUNC(PyInterpreterState *) _PyInterpreterID_LookUp(PyObject *);

Include/internal/pycore_interp_id.h

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

Include/interpreteridobject.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef Py_INTERPRETERIDOBJECT_H
2+
#define Py_INTERPRETERIDOBJECT_H
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
#ifndef Py_LIMITED_API
9+
# define Py_CPYTHON_INTERPRETERIDOBJECT_H
10+
# include "cpython/interpreteridobject.h"
11+
# undef Py_CPYTHON_INTERPRETERIDOBJECT_H
12+
#endif
13+
14+
#ifdef __cplusplus
15+
}
16+
#endif
17+
#endif /* !Py_INTERPRETERIDOBJECT_H */

Makefile.pre.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,7 @@ PYTHON_HEADERS= \
16311631
$(srcdir)/Include/floatobject.h \
16321632
$(srcdir)/Include/frameobject.h \
16331633
$(srcdir)/Include/import.h \
1634+
$(srcdir)/Include/interpreteridobject.h \
16341635
$(srcdir)/Include/intrcheck.h \
16351636
$(srcdir)/Include/iterobject.h \
16361637
$(srcdir)/Include/listobject.h \
@@ -1700,6 +1701,7 @@ PYTHON_HEADERS= \
17001701
$(srcdir)/Include/cpython/genobject.h \
17011702
$(srcdir)/Include/cpython/import.h \
17021703
$(srcdir)/Include/cpython/initconfig.h \
1704+
$(srcdir)/Include/cpython/interpreteridobject.h \
17031705
$(srcdir)/Include/cpython/listobject.h \
17041706
$(srcdir)/Include/cpython/longintrepr.h \
17051707
$(srcdir)/Include/cpython/longobject.h \
@@ -1771,7 +1773,6 @@ PYTHON_HEADERS= \
17711773
$(srcdir)/Include/internal/pycore_import.h \
17721774
$(srcdir)/Include/internal/pycore_initconfig.h \
17731775
$(srcdir)/Include/internal/pycore_interp.h \
1774-
$(srcdir)/Include/internal/pycore_interp_id.h \
17751776
$(srcdir)/Include/internal/pycore_intrinsics.h \
17761777
$(srcdir)/Include/internal/pycore_list.h \
17771778
$(srcdir)/Include/internal/pycore_long.h \

Modules/_testinternalcapi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@
1313
#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
1414
#include "pycore_bitutils.h" // _Py_bswap32()
1515
#include "pycore_bytesobject.h" // _PyBytes_Find()
16-
#include "pycore_ceval.h" // _PyEval_AddPendingCall
1716
#include "pycore_compile.h" // _PyCompile_CodeGen, _PyCompile_OptimizeCfg, _PyCompile_Assemble, _PyCompile_CleanDoc
17+
#include "pycore_ceval.h" // _PyEval_AddPendingCall
1818
#include "pycore_fileutils.h" // _Py_normpath
1919
#include "pycore_frame.h" // _PyInterpreterFrame
2020
#include "pycore_gc.h" // PyGC_Head
2121
#include "pycore_hashtable.h" // _Py_hashtable_new()
2222
#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
2323
#include "pycore_interp.h" // _PyInterpreterState_GetConfigCopy()
24-
#include "pycore_interp_id.h" // _PyInterpreterID_LookUp()
25-
#include "pycore_object.h" // _PyObject_IsFreed()
24+
#include "pycore_object.h" // _PyObject_IsFreed()
2625
#include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal()
2726
#include "pycore_pyerrors.h" // _Py_UTF8_Edit_Cost()
2827
#include "pycore_pystate.h" // _PyThreadState_GET()
2928

3029
#include "frameobject.h"
30+
#include "interpreteridobject.h" // _PyInterpreterID_LookUp()
3131
#include "osdefs.h" // MAXPATHLEN
3232

3333
#include "clinic/_testinternalcapi.c.h"
3434

3535
#ifdef MS_WINDOWS
36-
# include <winsock2.h> // struct timeval
36+
# include <winsock2.h> // struct timeval
3737
#endif
3838

3939

Modules/_xxinterpchannelsmodule.c

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

88
#include "Python.h"
9-
#include "pycore_interp_id.h" // _PyInterpreterState_GetIDObject()
9+
#include "interpreteridobject.h"
1010

1111

1212
/*

Modules/_xxsubinterpretersmodule.c

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

88
#include "Python.h"
9-
#include "pycore_interp_id.h" // _PyInterpreterState_GetIDObject()
9+
#include "interpreteridobject.h"
1010

1111

1212
#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 "pycore_interp_id.h" // _PyInterpreterID_Type
6+
#include "interpreteridobject.h"
77

88

99
typedef struct interpid {

Objects/object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
#include "pycore_dict.h" // _PyObject_MakeDictFromInstanceAttributes()
1010
#include "pycore_floatobject.h" // _PyFloat_DebugMallocStats()
1111
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
12-
#include "pycore_interp_id.h" // _PyInterpreterID_Type
1312
#include "pycore_namespace.h" // _PyNamespace_Type
1413
#include "pycore_object.h" // PyAPI_DATA() _Py_SwappedOp definition
1514
#include "pycore_pyerrors.h" // _PyErr_Occurred()
1615
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
1716
#include "pycore_pystate.h" // _PyThreadState_GET()
1817
#include "pycore_symtable.h" // PySTEntry_Type
19-
#include "pycore_typeobject.h" // _PyBufferWrapper_Type
2018
#include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic
19+
#include "pycore_typeobject.h" // _PyBufferWrapper_Type
2120
#include "pycore_unionobject.h" // _PyUnion_Type
21+
#include "interpreteridobject.h" // _PyInterpreterID_Type
2222

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

PCbuild/pythoncore.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
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" />
155156
<ClInclude Include="..\Include\cpython\listobject.h" />
156157
<ClInclude Include="..\Include\cpython\longintrepr.h" />
157158
<ClInclude Include="..\Include\cpython\longobject.h" />
@@ -237,7 +238,6 @@
237238
<ClInclude Include="..\Include\internal\pycore_import.h" />
238239
<ClInclude Include="..\Include\internal\pycore_initconfig.h" />
239240
<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,6 +281,7 @@
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" />
284285
<ClInclude Include="..\Include\intrcheck.h" />
285286
<ClInclude Include="..\Include\iterobject.h" />
286287
<ClInclude Include="..\Include\listobject.h" />

0 commit comments

Comments
 (0)