From 2276c6cb42025d5d7056b0d8efc247f6fef39633 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 23 Feb 2022 20:21:30 +0100 Subject: [PATCH 1/2] bpo-45459: Fix object.h: don't define PyObject type twice It's already defined in pybuffer.h. --- Include/object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Include/object.h b/Include/object.h index 3566c736a535c4..ac8017aa530acc 100644 --- a/Include/object.h +++ b/Include/object.h @@ -102,11 +102,11 @@ typedef struct _typeobject PyTypeObject; * by hand. Similarly every pointer to a variable-size Python object can, * in addition, be cast to PyVarObject*. */ -typedef struct _object { +struct _object { _PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt; PyTypeObject *ob_type; -} PyObject; +}; /* Cast argument to PyObject* type. */ #define _PyObject_CAST(op) ((PyObject*)(op)) From a36cec059b0a090d348d7ed006cd2c674053cd78 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 23 Feb 2022 22:11:00 +0100 Subject: [PATCH 2/2] Fix pybuffer.h --- Include/pybuffer.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Include/pybuffer.h b/Include/pybuffer.h index 31795b780710fa..923006cff36233 100644 --- a/Include/pybuffer.h +++ b/Include/pybuffer.h @@ -6,6 +6,10 @@ extern "C" { #endif +// 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; + #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 /* === New Buffer API ============================================ @@ -17,10 +21,6 @@ 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 */