Skip to content

Commit 871eb42

Browse files
author
Erlend Egeberg Aasland
authored
bpo-40170: Convert PyDescr_IsData() to static inline function (GH-24535)
1 parent 8a8b5df commit 871eb42

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

Doc/c-api/descriptor.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ found in the dictionary of type objects.
3232
3333
.. c:function:: int PyDescr_IsData(PyObject *descr)
3434
35-
Return true if the descriptor objects *descr* describes a data attribute, or
36-
false if it describes a method. *descr* must be a descriptor object; there is
35+
Return non-zero if the descriptor objects *descr* describes a data attribute, or
36+
``0`` if it describes a method. *descr* must be a descriptor object; there is
3737
no error checking.
3838
3939

Include/descrobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
9393
#ifndef Py_LIMITED_API
9494
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
9595
struct wrapperbase *, void *);
96-
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
96+
PyAPI_FUNC(int) PyDescr_IsData(PyObject *);
9797
#endif
9898

9999
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Convert :c:func:`PyDescr_IsData` macro to a function to hide implementation
2+
details: The macro accessed :c:member:`PyTypeObject.tp_descr_set` directly.
3+
Patch by Erlend E. Aasland.

Objects/descrobject.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,11 @@ PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
995995
return (PyObject *)descr;
996996
}
997997

998+
int
999+
PyDescr_IsData(PyObject *ob)
1000+
{
1001+
return Py_TYPE(ob)->tp_descr_set != NULL;
1002+
}
9981003

9991004
/* --- mappingproxy: read-only proxy for mappings --- */
10001005

0 commit comments

Comments
 (0)