bpo-45459: Rename buffer.h to pybuffer.h (#31201)

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.
This commit is contained in:
Victor Stinner 2022-02-22 23:11:48 +01:00 committed by GitHub
parent b899126094
commit 66b3cd7063
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 4 deletions

View 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"

View 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

View 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 */

View 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 \

View file

@ -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.

View file

@ -263,6 +263,7 @@
<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" />

View file

@ -147,6 +147,9 @@
<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>