From ec13b9322d95a651606219469fc7b7e9c977f248 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 25 Nov 2018 23:56:17 +0100 Subject: [PATCH] bpo-35081: Add Include/internal/pycore_tupleobject.h (GH-10705) Move _PyTuple_ITEMS() to a new header file: Include/internal/pycore_tupleobject.h --- Include/internal/pycore_tupleobject.h | 18 ++++++++++++++++++ Include/tupleobject.h | 4 ---- Makefile.pre.in | 1 + Modules/_functoolsmodule.c | 2 +- Objects/call.c | 1 + Objects/codeobject.c | 1 + Objects/descrobject.c | 1 + Objects/funcobject.c | 1 + PCbuild/pythoncore.vcxproj | 1 + PCbuild/pythoncore.vcxproj.filters | 3 +++ Python/ceval.c | 1 + Python/getargs.c | 1 + 12 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 Include/internal/pycore_tupleobject.h diff --git a/Include/internal/pycore_tupleobject.h b/Include/internal/pycore_tupleobject.h new file mode 100644 index 00000000000..fdd74146766 --- /dev/null +++ b/Include/internal/pycore_tupleobject.h @@ -0,0 +1,18 @@ +#ifndef Py_INTERNAL_TUPLEOBJECT_H +#define Py_INTERNAL_TUPLEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) +# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define" +#endif + +#include "tupleobject.h" + +#define _PyTuple_ITEMS(op) (_PyTuple_CAST(op)->ob_item) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_TUPLEOBJECT_H */ diff --git a/Include/tupleobject.h b/Include/tupleobject.h index a150d07d3e0..eec2d98f2d9 100644 --- a/Include/tupleobject.h +++ b/Include/tupleobject.h @@ -61,10 +61,6 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); #define PyTuple_GET_ITEM(op, i) (_PyTuple_CAST(op)->ob_item[i]) #define PyTuple_GET_SIZE(op) (assert(PyTuple_Check(op)), Py_SIZE(op)) -#ifdef Py_BUILD_CORE -# define _PyTuple_ITEMS(op) (_PyTuple_CAST(op)->ob_item) -#endif - /* Macro, *only* to be used to fill in brand new tuples */ #define PyTuple_SET_ITEM(op, i, v) (_PyTuple_CAST(op)->ob_item[i] = v) #endif diff --git a/Makefile.pre.in b/Makefile.pre.in index d0e915a00ae..2c92db23489 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1043,6 +1043,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_pylifecycle.h \ $(srcdir)/Include/internal/pycore_pymem.h \ $(srcdir)/Include/internal/pycore_pystate.h \ + $(srcdir)/Include/internal/pycore_tupleobject.h \ $(srcdir)/Include/internal/pycore_warnings.h \ $(DTRACE_HEADERS) diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 773102bb590..8701f6c89d7 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1,7 +1,7 @@ - #include "Python.h" #include "pycore_pymem.h" #include "pycore_pystate.h" +#include "pycore_tupleobject.h" #include "structmember.h" /* _functools module written and maintained diff --git a/Objects/call.c b/Objects/call.c index ce346c29348..ba2ddcb35b9 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -1,6 +1,7 @@ #include "Python.h" #include "pycore_object.h" #include "pycore_pystate.h" +#include "pycore_tupleobject.h" #include "frameobject.h" diff --git a/Objects/codeobject.c b/Objects/codeobject.c index a2efa7ed03f..09182d61c24 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -4,6 +4,7 @@ #include "code.h" #include "structmember.h" #include "pycore_pystate.h" +#include "pycore_tupleobject.h" /* Holder for co_extra information */ typedef struct { diff --git a/Objects/descrobject.c b/Objects/descrobject.c index dd3c5014aea..23d4b1a29e6 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -3,6 +3,7 @@ #include "Python.h" #include "pycore_object.h" #include "pycore_pystate.h" +#include "pycore_tupleobject.h" #include "structmember.h" /* Why is this not included in Python.h? */ /*[clinic input] diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 982df5434d2..c77e4e9f4e8 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -5,6 +5,7 @@ #include "pycore_object.h" #include "pycore_pymem.h" #include "pycore_pystate.h" +#include "pycore_tupleobject.h" #include "code.h" #include "structmember.h" diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 34cd3796888..8aa4c0610f6 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -127,6 +127,7 @@ + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index ebe5e8a169f..021a67efccb 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -180,6 +180,9 @@ Include + + Include + Include diff --git a/Python/ceval.c b/Python/ceval.c index 7b2465592a4..a4273adee48 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -12,6 +12,7 @@ #include "Python.h" #include "pycore_object.h" #include "pycore_pystate.h" +#include "pycore_tupleobject.h" #include "code.h" #include "dictobject.h" diff --git a/Python/getargs.c b/Python/getargs.c index 89df29e3152..ac8bac3bf50 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -2,6 +2,7 @@ /* New getargs implementation */ #include "Python.h" +#include "pycore_tupleobject.h" #include #include