]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40170: Convert PyDescr_IsData() to static inline function (GH-24535)
authorErlend Egeberg Aasland <erlend.aasland@innova.no>
Tue, 16 Feb 2021 07:50:00 +0000 (08:50 +0100)
committerGitHub <noreply@github.com>
Tue, 16 Feb 2021 07:50:00 +0000 (08:50 +0100)
Doc/c-api/descriptor.rst
Include/descrobject.h
Misc/NEWS.d/next/Core and Builtins/2021-02-15-13-41-14.bpo-40170.r2FAtl.rst [new file with mode: 0644]
Objects/descrobject.c

index 1005140c7acb3ac8e45928f0b408673564aa7fb1..b32c113e5f04573a04fd53f20c267cbd79897079 100644 (file)
@@ -32,8 +32,8 @@ found in the dictionary of type objects.
 
 .. c:function:: int PyDescr_IsData(PyObject *descr)
 
-   Return true if the descriptor objects *descr* describes a data attribute, or
-   false if it describes a method.  *descr* must be a descriptor object; there is
+   Return non-zero if the descriptor objects *descr* describes a data attribute, or
+   ``0`` if it describes a method.  *descr* must be a descriptor object; there is
    no error checking.
 
 
index ead269d1d2f796b5f4cf9c00284f9da7f5e79964..703bc8fd6df21340378a72dee812f017e8940a37 100644 (file)
@@ -93,7 +93,7 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
 #ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
                                                 struct wrapperbase *, void *);
-#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
+PyAPI_FUNC(int) PyDescr_IsData(PyObject *);
 #endif
 
 PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-02-15-13-41-14.bpo-40170.r2FAtl.rst b/Misc/NEWS.d/next/Core and Builtins/2021-02-15-13-41-14.bpo-40170.r2FAtl.rst
new file mode 100644 (file)
index 0000000..82e844b
--- /dev/null
@@ -0,0 +1,3 @@
+Convert :c:func:`PyDescr_IsData` macro to a function to hide implementation
+details: The macro accessed :c:member:`PyTypeObject.tp_descr_set` directly.
+Patch by Erlend E. Aasland.
index 16c695a08f47d95cac669930ae480326000b8487..35fbffd914a94c72eafdde2e3c505ecc4ed694b0 100644 (file)
@@ -995,6 +995,11 @@ PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
     return (PyObject *)descr;
 }
 
+int
+PyDescr_IsData(PyObject *ob)
+{
+    return Py_TYPE(ob)->tp_descr_set != NULL;
+}
 
 /* --- mappingproxy: read-only proxy for mappings --- */