]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45459: Rename buffer.h to pybuffer.h (#31201)
authorVictor Stinner <vstinner@python.org>
Tue, 22 Feb 2022 22:11:48 +0000 (23:11 +0100)
committerGitHub <noreply@github.com>
Tue, 22 Feb 2022 22:11:48 +0000 (23:11 +0100)
Rename Include/buffer.h header file to Include/pybuffer.h to avoid
conflicts with projects having an existing "buffer.h" header file.

* Incude pybuffer.h before object.h in Python.h.
* Remove #include "buffer.h" from Include/cpython/object.h.
* Add a forward declaration of the PyObject type in pybuffer.h to fix
  an inter-dependency issue.

Include/Python.h
Include/cpython/object.h
Include/pybuffer.h [moved from Include/buffer.h with 96% similarity]
Makefile.pre.in
Misc/NEWS.d/next/C API/2022-02-07-18-47-00.bpo-45459.0FCWM8.rst [new file with mode: 0644]
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters

index 5416b04e4bfb329626409f05dc5e574ce0cf9818..5bc8cc656af0de6e5d67b2d477fc3a2ab197da9b 100644 (file)
@@ -39,6 +39,7 @@
 #include "pymacro.h"
 #include "pymath.h"
 #include "pymem.h"
+#include "pybuffer.h"
 #include "object.h"
 #include "objimpl.h"
 #include "typeslots.h"
@@ -50,7 +51,6 @@
 #include "longobject.h"
 #include "cpython/longintrepr.h"
 #include "boolobject.h"
-#include "buffer.h"
 #include "floatobject.h"
 #include "complexobject.h"
 #include "rangeobject.h"
index 2ee97ba0b40af576a70f8bb449d96fb493513ad9..6cc3d72ca7084978f57ae9945a7cb93b8ff4fa0d 100644 (file)
@@ -2,8 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-#include "buffer.h" // for Py_buffer, included after PyObject has been defined
-
 PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
 
 #ifdef Py_TRACE_REFS
similarity index 96%
rename from Include/buffer.h
rename to Include/pybuffer.h
index 6893505e66e3e812448d651451cca5e194e0f88f..31795b780710fa7c2b752de6f74df6050f24bbf5 100644 (file)
@@ -17,6 +17,10 @@ extern "C" {
  *
  */
 
+// Forward declaration to be able to include pybuffer.h before object.h:
+// pybuffer.h uses PyObject and object.h uses Py_buffer.
+typedef struct _object PyObject;
+
 typedef struct {
     void *buf;
     PyObject *obj;        /* owned reference */
index 2464bbdf2ddd000e5f42ff440c8c29df163cbe1b..2a3e0fbceb4c07cec5977fb91ab90c2bc327b081 100644 (file)
@@ -1439,7 +1439,6 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/abstract.h \
                $(srcdir)/Include/bltinmodule.h \
                $(srcdir)/Include/boolobject.h \
-               $(srcdir)/Include/buffer.h \
                $(srcdir)/Include/bytearrayobject.h \
                $(srcdir)/Include/bytesobject.h \
                $(srcdir)/Include/ceval.h \
@@ -1472,6 +1471,7 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/osdefs.h \
                $(srcdir)/Include/osmodule.h \
                $(srcdir)/Include/patchlevel.h \
+               $(srcdir)/Include/pybuffer.h \
                $(srcdir)/Include/pycapsule.h \
                $(srcdir)/Include/pydtrace.h \
                $(srcdir)/Include/pyerrors.h \
diff --git a/Misc/NEWS.d/next/C API/2022-02-07-18-47-00.bpo-45459.0FCWM8.rst b/Misc/NEWS.d/next/C API/2022-02-07-18-47-00.bpo-45459.0FCWM8.rst
new file mode 100644 (file)
index 0000000..711c107
--- /dev/null
@@ -0,0 +1,3 @@
+Rename ``Include/buffer.h`` header file to ``Include/pybuffer.h`` to avoid
+conflits with projects having an existing ``buffer.h`` header file. Patch by
+Victor Stinner.
index 8f9c4fe63b8dc9833e2902900f76761f5ca707f6..c2f1a016bc11155e28a58f70a2d7274cca409876 100644 (file)
     <ClInclude Include="..\Include\osmodule.h" />
     <ClInclude Include="..\Include\patchlevel.h" />
     <ClInclude Include="..\Include\py_curses.h" />
+    <ClInclude Include="..\Include\pybuffer.h" />
     <ClInclude Include="..\Include\pycapsule.h" />
     <ClInclude Include="..\Include\pyerrors.h" />
     <ClInclude Include="..\Include\pyexpat.h" />
index dc3b554779486342d2928c1535e153bfc037c457..b300103bbb42062de1c1a7e1766dfed48c2d2cca 100644 (file)
     <ClInclude Include="..\Include\py_curses.h">
       <Filter>Include</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\pybuffer.h">
+      <Filter>Include</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\pycapsule.h">
       <Filter>Include</Filter>
     </ClInclude>