bpo-40170: Convert PyDescr_IsData() to static inline function (GH-24535) · python/cpython@871eb42 (original) (raw)
File tree
4 files changed
lines changed
- Misc/NEWS.d/next/Core and Builtins
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -32,8 +32,8 @@ found in the dictionary of type objects. | ||
32 | 32 | |
33 | 33 | .. c:function:: int PyDescr_IsData(PyObject *descr) |
34 | 34 | |
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 | |
37 | 37 | no error checking. |
38 | 38 | |
39 | 39 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -93,7 +93,7 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, | ||
93 | 93 | #ifndef Py_LIMITED_API |
94 | 94 | PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, |
95 | 95 | struct wrapperbase *, void *); |
96 | -#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) | |
96 | +PyAPI_FUNC(int) PyDescr_IsData(PyObject *); | |
97 | 97 | #endif |
98 | 98 | |
99 | 99 | PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); |
Original file line number | Diff line number | Diff 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -995,6 +995,11 @@ PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped) | ||
995 | 995 | return (PyObject *)descr; |
996 | 996 | } |
997 | 997 | |
998 | +int | |
999 | +PyDescr_IsData(PyObject *ob) | |
1000 | +{ | |
1001 | +return Py_TYPE(ob)->tp_descr_set != NULL; | |
1002 | +} | |
998 | 1003 | |
999 | 1004 | /* --- mappingproxy: read-only proxy for mappings --- */ |
1000 | 1005 |