https://github.com/python/cpython/commit/ec13b9322d95a651606219469fc7b7e9c97... commit: ec13b9322d95a651606219469fc7b7e9c977f248 branch: master author: Victor Stinner <vstinner@redhat.com> committer: GitHub <noreply@github.com> date: 2018-11-25T23:56:17+01:00 summary: bpo-35081: Add Include/internal/pycore_tupleobject.h (GH-10705) Move _PyTuple_ITEMS() to a new header file: Include/internal/pycore_tupleobject.h files: A Include/internal/pycore_tupleobject.h M Include/tupleobject.h M Makefile.pre.in M Modules/_functoolsmodule.c M Objects/call.c M Objects/codeobject.c M Objects/descrobject.c M Objects/funcobject.c M PCbuild/pythoncore.vcxproj M PCbuild/pythoncore.vcxproj.filters M Python/ceval.c M Python/getargs.c diff --git a/Include/internal/pycore_tupleobject.h b/Include/internal/pycore_tupleobject.h new file mode 100644 index 000000000000..fdd741467665 --- /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 a150d07d3e0a..eec2d98f2d95 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 d0e915a00ae0..2c92db23489e 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 773102bb5900..8701f6c89d71 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 ce346c293486..ba2ddcb35b9b 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 a2efa7ed03f5..09182d61c244 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 dd3c5014aea7..23d4b1a29e6f 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 982df5434d25..c77e4e9f4e89 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 34cd3796888c..8aa4c0610f60 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -127,6 +127,7 @@ <ClInclude Include="..\Include\internal\pycore_pylifecycle.h" /> <ClInclude Include="..\Include\internal\pycore_pymem.h" /> <ClInclude Include="..\Include\internal\pycore_pystate.h" /> + <ClInclude Include="..\Include\internal\pycore_tupleobject.h" /> <ClInclude Include="..\Include\internal\pycore_warnings.h" /> <ClInclude Include="..\Include\intrcheck.h" /> <ClInclude Include="..\Include\iterobject.h" /> diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index ebe5e8a169fd..021a67efccbc 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -180,6 +180,9 @@ <ClInclude Include="..\Include\internal\pycore_pystate.h"> <Filter>Include</Filter> </ClInclude> + <ClInclude Include="..\Include\internal\pycore_tupleobject.h"> + <Filter>Include</Filter> + </ClInclude> <ClInclude Include="..\Include\internal\pycore_warnings.h"> <Filter>Include</Filter> </ClInclude> diff --git a/Python/ceval.c b/Python/ceval.c index 7b2465592a4b..a4273adee48d 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 89df29e31527..ac8bac3bf50b 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -2,6 +2,7 @@ /* New getargs implementation */ #include "Python.h" +#include "pycore_tupleobject.h" #include <ctype.h> #include <float.h>