]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41078: Add pycore_list.h internal header file (GH-21057)
authorVictor Stinner <vstinner@python.org>
Mon, 22 Jun 2020 15:39:32 +0000 (17:39 +0200)
committerGitHub <noreply@github.com>
Mon, 22 Jun 2020 15:39:32 +0000 (17:39 +0200)
* Move _PyList_ITEMS() to pycore_list.h.
* The C extension "_heapq" is now built with Py_BUILD_CORE_MODULE
  macro defined to access the internal C API.

Include/cpython/listobject.h
Include/internal/pycore_list.h [new file with mode: 0644]
Makefile.pre.in
Modules/Setup
Modules/_heapqmodule.c
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
setup.py

index b1af5f6764427f37dea64029e43879135902772c..70b9d83d8a232cc34d1e85fcdcf482b62aa15089 100644 (file)
@@ -32,4 +32,3 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
 #define PyList_GET_ITEM(op, i) (_PyList_CAST(op)->ob_item[i])
 #define PyList_SET_ITEM(op, i, v) (_PyList_CAST(op)->ob_item[i] = (v))
 #define PyList_GET_SIZE(op)    Py_SIZE(_PyList_CAST(op))
-#define _PyList_ITEMS(op)      (_PyList_CAST(op)->ob_item)
diff --git a/Include/internal/pycore_list.h b/Include/internal/pycore_list.h
new file mode 100644 (file)
index 0000000..f18fb05
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef Py_INTERNAL_LIST_H
+#define Py_INTERNAL_LIST_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+#  error "this header requires Py_BUILD_CORE define"
+#endif
+
+#include "listobject.h"           // _PyList_CAST()
+
+
+#define _PyList_ITEMS(op) (_PyList_CAST(op)->ob_item)
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif   /* !Py_INTERNAL_LIST_H */
index a52a97f7969a7faacccdc6d9e37241ff1f916301..3428b9842a5a0f7eb3803b78b87b8899f5c14ab5 100644 (file)
@@ -1110,6 +1110,7 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/internal/pycore_import.h \
                $(srcdir)/Include/internal/pycore_initconfig.h \
                $(srcdir)/Include/internal/pycore_interp.h \
+               $(srcdir)/Include/internal/pycore_list.h \
                $(srcdir)/Include/internal/pycore_object.h \
                $(srcdir)/Include/internal/pycore_pathconfig.h \
                $(srcdir)/Include/internal/pycore_pyerrors.h \
index 5d428d5b8baa74ff02533417d63d076be65ec8ae..470bf6bc2efbf5b4debecffe07c40e714a1341b4 100644 (file)
@@ -180,7 +180,7 @@ _symtable symtablemodule.c
 #_datetime _datetimemodule.c   # datetime accelerator
 #_zoneinfo _zoneinfo.c # zoneinfo accelerator
 #_bisect _bisectmodule.c       # Bisection algorithms
-#_heapq _heapqmodule.c # Heap queue algorithm
+#_heapq _heapqmodule.c -DPy_BUILD_CORE_MODULE  # Heap queue algorithm
 #_asyncio _asynciomodule.c  # Fast asyncio Future
 #_json -I$(srcdir)/Include/internal -DPy_BUILD_CORE_BUILTIN _json.c    # _json speedups
 #_statistics _statisticsmodule.c # statistics accelerator
index 193478d79b45687139179a5fc44b0c0d25fcbe01..20468c28f24234ad7f5374408d60eaf2eee6e88b 100644 (file)
@@ -7,9 +7,11 @@ annotated by François Pinard, and converted to C by Raymond Hettinger.
 */
 
 #include "Python.h"
+#include "pycore_list.h"          // _PyList_ITEMS()
 
 #include "clinic/_heapqmodule.c.h"
 
+
 /*[clinic input]
 module _heapq
 [clinic start generated code]*/
index 00714757f64f2f0ca1d78a6b22ee30b527aa44a9..54e23c2c2b505672f809a267670c666a80377aff 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_abstract.h" />
     <ClInclude Include="..\Include\internal\pycore_accu.h" />
     <ClInclude Include="..\Include\internal\pycore_atomic.h" />
-    <ClInclude Include="..\Include\internal\pycore_bytes_methods.h" />
     <ClInclude Include="..\Include\internal\pycore_bitutils.h" />
+    <ClInclude Include="..\Include\internal\pycore_bytes_methods.h" />
     <ClInclude Include="..\Include\internal\pycore_call.h" />
     <ClInclude Include="..\Include\internal\pycore_ceval.h" />
     <ClInclude Include="..\Include\internal\pycore_code.h" />
     <ClInclude Include="..\Include\internal\pycore_import.h" />
     <ClInclude Include="..\Include\internal\pycore_initconfig.h" />
     <ClInclude Include="..\Include\internal\pycore_interp.h" />
+    <ClInclude Include="..\Include\internal\pycore_list.h" />
     <ClInclude Include="..\Include\internal\pycore_object.h" />
     <ClInclude Include="..\Include\internal\pycore_pathconfig.h" />
     <ClInclude Include="..\Include\internal\pycore_pyerrors.h" />
index ddcdaf471901cdff5e0d581aec210e9f721bb661..4ba0bc2ac3bfa8142f214d7cd928448a21c0ae12 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_interp.h">
       <Filter>Include</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_list.h">
+      <Filter>Include</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_object.h">
       <Filter>Include</Filter>
     </ClInclude>
index 648e4e6a8932e7b73e8fa1ec5accab4c65ff865d..21a5a58981fc15319b1052c7dbe5cca82b4d10dd 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -863,7 +863,8 @@ class PyBuildExt(build_ext):
         # bisect
         self.add(Extension("_bisect", ["_bisectmodule.c"]))
         # heapq
-        self.add(Extension("_heapq", ["_heapqmodule.c"]))
+        self.add(Extension("_heapq", ["_heapqmodule.c"],
+                           extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
         # C-optimized pickle replacement
         self.add(Extension("_pickle", ["_pickle.c"],
                            extra_compile_args=['-DPy_BUILD_CORE_MODULE']))