From 680df71eb7585ebe08c5cf31ecc0507e6fedb2a9 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 2 Jun 2023 16:20:43 -0600 Subject: [PATCH 1/4] Revert "bpo-35081: Move interpreteridobject.h to Include/internal/ (GH-28969)" This reverts commit 063abd931f064a4b6b478b0b6e9aa13ee38d2cff. --- .../interpreteridobject.h} | 17 +++-------------- Include/internal/pycore_pymem.h | 2 +- Include/interpreteridobject.h | 17 +++++++++++++++++ Makefile.pre.in | 3 ++- Modules/_xxinterpchannelsmodule.c | 2 +- Modules/_xxsubinterpretersmodule.c | 2 +- Objects/interpreteridobject.c | 2 +- Objects/object.c | 2 +- PCbuild/pythoncore.vcxproj | 3 ++- PCbuild/pythoncore.vcxproj.filters | 9 ++++++--- Tools/c-analyzer/cpython/_parser.py | 1 + 11 files changed, 36 insertions(+), 24 deletions(-) rename Include/{internal/pycore_interpreteridobject.h => cpython/interpreteridobject.h} (51%) create mode 100644 Include/interpreteridobject.h diff --git a/Include/internal/pycore_interpreteridobject.h b/Include/cpython/interpreteridobject.h similarity index 51% rename from Include/internal/pycore_interpreteridobject.h rename to Include/cpython/interpreteridobject.h index 804831e76deaea..5076584209b90b 100644 --- a/Include/internal/pycore_interpreteridobject.h +++ b/Include/cpython/interpreteridobject.h @@ -1,22 +1,11 @@ -/* Interpreter ID Object */ - -#ifndef Py_INTERNAL_INTERPRETERIDOBJECT_H -#define Py_INTERNAL_INTERPRETERIDOBJECT_H -#ifdef __cplusplus -extern "C" { +#ifndef Py_CPYTHON_INTERPRETERIDOBJECT_H +# error "this header file must not be included directly" #endif -#ifndef Py_BUILD_CORE -# error "this header requires Py_BUILD_CORE define" -#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 *); - -#ifdef __cplusplus -} -#endif -#endif // !Py_INTERNAL_INTERPRETERIDOBJECT_H diff --git a/Include/internal/pycore_pymem.h b/Include/internal/pycore_pymem.h index 4cc953d8d779c9..a555f373001181 100644 --- a/Include/internal/pycore_pymem.h +++ b/Include/internal/pycore_pymem.h @@ -94,4 +94,4 @@ PyAPI_FUNC(int) _PyMem_SetupAllocators(PyMemAllocatorName allocator); #ifdef __cplusplus } #endif -#endif // !Py_INTERNAL_PYMEM_H +#endif /* !Py_INTERNAL_PYMEM_H */ diff --git a/Include/interpreteridobject.h b/Include/interpreteridobject.h new file mode 100644 index 00000000000000..8432632f339e92 --- /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 */ diff --git a/Makefile.pre.in b/Makefile.pre.in index b66530928eeea9..ae428ebb9a25f3 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1618,6 +1618,7 @@ 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 \ @@ -1688,6 +1689,7 @@ 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 \ @@ -1756,7 +1758,6 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_import.h \ $(srcdir)/Include/internal/pycore_initconfig.h \ $(srcdir)/Include/internal/pycore_interp.h \ - $(srcdir)/Include/internal/pycore_interpreteridobject.h \ $(srcdir)/Include/internal/pycore_intrinsics.h \ $(srcdir)/Include/internal/pycore_list.h \ $(srcdir)/Include/internal/pycore_long.h \ diff --git a/Modules/_xxinterpchannelsmodule.c b/Modules/_xxinterpchannelsmodule.c index 616dd577688116..3214d5f61e1dd1 100644 --- a/Modules/_xxinterpchannelsmodule.c +++ b/Modules/_xxinterpchannelsmodule.c @@ -6,8 +6,8 @@ #endif #include "Python.h" +#include "interpreteridobject.h" #include "pycore_pystate.h" // _PyThreadState_GET() -#include "pycore_interpreteridobject.h" /* diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c index d7daae254638ec..02871363fef0de 100644 --- a/Modules/_xxsubinterpretersmodule.c +++ b/Modules/_xxsubinterpretersmodule.c @@ -6,10 +6,10 @@ #endif #include "Python.h" +#include "interpreteridobject.h" // XXX This module should not rely on internal API. #include "pycore_frame.h" #include "pycore_pystate.h" // _PyThreadState_GET() -#include "pycore_interpreteridobject.h" #define MODULE_NAME "_xxsubinterpreters" diff --git a/Objects/interpreteridobject.c b/Objects/interpreteridobject.c index 7b3e31beded594..46239100dcb7b7 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 "pycore_interpreteridobject.h" +#include "interpreteridobject.h" typedef struct interpid { diff --git a/Objects/object.c b/Objects/object.c index 824c4e4a7328f0..b20e87ef3fb23d 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -17,7 +17,7 @@ #include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic #include "pycore_typeobject.h" // _PyBufferWrapper_Type #include "pycore_unionobject.h" // _PyUnion_Type -#include "pycore_interpreteridobject.h" // _PyInterpreterID_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 611dba3dbb7f12..72d869efb9db67 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -152,6 +152,7 @@ + @@ -234,7 +235,6 @@ - @@ -275,6 +275,7 @@ + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 45427b28ca9fa7..5d8b7196c14e6a 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -315,6 +315,9 @@ Include + + Include + Modules @@ -459,6 +462,9 @@ Include + + Include\cpython + Include\cpython @@ -603,9 +609,6 @@ Include\internal - - Include\cpython - Include\cpython diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py index 0f6edc7df3e3ad..51b79c25f9e20b 100644 --- a/Tools/c-analyzer/cpython/_parser.py +++ b/Tools/c-analyzer/cpython/_parser.py @@ -226,6 +226,7 @@ def clean_lines(text): 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 From 452f99e0f2914d070e535829db068df7b203482b Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 2 Jun 2023 16:22:04 -0600 Subject: [PATCH 2/4] Drop internal includes from _xxsubinterpreters. --- Modules/_xxsubinterpretersmodule.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c index 02871363fef0de..9a184775b9bac8 100644 --- a/Modules/_xxsubinterpretersmodule.c +++ b/Modules/_xxsubinterpretersmodule.c @@ -7,9 +7,6 @@ #include "Python.h" #include "interpreteridobject.h" -// XXX This module should not rely on internal API. -#include "pycore_frame.h" -#include "pycore_pystate.h" // _PyThreadState_GET() #define MODULE_NAME "_xxsubinterpreters" @@ -376,7 +373,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 +509,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 From 2ff0beddaa74b9df70556743aae04798a72d1c61 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 2 Jun 2023 16:23:08 -0600 Subject: [PATCH 3/4] Drop internal includes from _xxinterpchannels. --- Modules/_xxinterpchannelsmodule.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/_xxinterpchannelsmodule.c b/Modules/_xxinterpchannelsmodule.c index 3214d5f61e1dd1..4fbac0a4a9f604 100644 --- a/Modules/_xxinterpchannelsmodule.c +++ b/Modules/_xxinterpchannelsmodule.c @@ -7,7 +7,6 @@ #include "Python.h" #include "interpreteridobject.h" -#include "pycore_pystate.h" // _PyThreadState_GET() /* From 4c101ee09fd7b4624dd470b39dad77568968c59c Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 2 Jun 2023 16:26:54 -0600 Subject: [PATCH 4/4] Do not build with the internal headers. --- Modules/_xxinterpchannelsmodule.c | 3 --- Modules/_xxsubinterpretersmodule.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/Modules/_xxinterpchannelsmodule.c b/Modules/_xxinterpchannelsmodule.c index 4fbac0a4a9f604..1d7e7f1d71af3e 100644 --- a/Modules/_xxinterpchannelsmodule.c +++ b/Modules/_xxinterpchannelsmodule.c @@ -1,9 +1,6 @@ /* interpreters module */ /* low-level access to interpreter primitives */ -#ifndef Py_BUILD_CORE_BUILTIN -# define Py_BUILD_CORE_MODULE 1 -#endif #include "Python.h" #include "interpreteridobject.h" diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c index 9a184775b9bac8..4801f37d6f6c5f 100644 --- a/Modules/_xxsubinterpretersmodule.c +++ b/Modules/_xxsubinterpretersmodule.c @@ -1,9 +1,6 @@ /* interpreters module */ /* low-level access to interpreter primitives */ -#ifndef Py_BUILD_CORE_BUILTIN -# define Py_BUILD_CORE_MODULE 1 -#endif #include "Python.h" #include "interpreteridobject.h" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy