aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-02-16 08:50:00 +0100
committerGitHub <noreply@github.com>2021-02-16 08:50:00 +0100
commit871eb4237b9be95263ca13ba8856e78344eb9eba (patch)
tree25e8e7ac21e5656233c0111593e0de37e304ce65
parentbpo-43155: Add PyCMethod_New to PC/python3dll.c (GH-24500) (diff)
downloadcpython-871eb4237b9be95263ca13ba8856e78344eb9eba.tar.gz
cpython-871eb4237b9be95263ca13ba8856e78344eb9eba.tar.bz2
cpython-871eb4237b9be95263ca13ba8856e78344eb9eba.zip
bpo-40170: Convert PyDescr_IsData() to static inline function (GH-24535)HEADmaster
-rw-r--r--Doc/c-api/descriptor.rst4
-rw-r--r--Include/descrobject.h2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2021-02-15-13-41-14.bpo-40170.r2FAtl.rst3
-rw-r--r--Objects/descrobject.c5
4 files changed, 11 insertions, 3 deletions
diff --git a/Doc/c-api/descriptor.rst b/Doc/c-api/descriptor.rst
index 1005140c7a..b32c113e5f 100644
--- a/Doc/c-api/descriptor.rst
+++ b/Doc/c-api/descriptor.rst
@@ -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.
diff --git a/Include/descrobject.h b/Include/descrobject.h
index ead269d1d2..703bc8fd6d 100644
--- a/Include/descrobject.h
+++ b/Include/descrobject.h
@@ -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
index 0000000000..82e844bc28
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-02-15-13-41-14.bpo-40170.r2FAtl.rst
@@ -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.
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 16c695a08f..35fbffd914 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -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 --- */