From cdfc3f3edb19e7a2d333bed992df8921470ac99a Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Fri, 23 Oct 2026 17:20:46 -0700 Subject: [PATCH] PEP 813: guard PyObject_Pretty() by limited API version PyObject_Pretty() is part of the limited API from 3.16, but it was declared without a version guard. An extension built against an older limited API, such as Py_LIMITED_API=0x030a0000, could compile against it and then fail to load on Python 3.10 through 3.15. Co-Authored-By: Claude Opus 5.5 --- Include/object.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Include/object.h b/Include/object.h index 4c96c9ea655fc1..a40f267eea8083 100644 --- a/Include/object.h +++ b/Include/object.h @@ -394,7 +394,9 @@ PyAPI_FUNC(void) PyType_Modified(PyTypeObject *); /* Generic operations on objects */ PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03100000 PyAPI_FUNC(PyObject *) PyObject_Pretty(PyObject *, PyObject *); +#endif PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *); PyAPI_FUNC(PyObject *) PyObject_Bytes(PyObject *); PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);