Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Revert "bpo-40170: PyType_HasFeature() now always calls PyType_GetFla…
…gs() (GH-19378)"

This partially reverts commit 45ec5b9.
  • Loading branch information
vstinner committed Jul 8, 2020
commit 4975a9eb773d0b9525315801f3e2ed3f79c432fb
12 changes: 10 additions & 2 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,16 @@ times.


static inline int
PyType_HasFeature(PyTypeObject *type, unsigned long feature) {
return ((PyType_GetFlags(type) & feature) != 0);
PyType_HasFeature(PyTypeObject *type, unsigned long feature)
{
unsigned long flags;
#ifdef Py_LIMITED_API
// PyTypeObject is opaque in the limited C API
flags = PyType_GetFlags(type);
#else
flags = type->tp_flags;
#endif
return ((flags & feature) != 0);
}

#define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Revert :c:func:`PyType_HasFeature` change: it reads again directly the
:c:member:`PyTypeObject.tp_flags` member when the limited C API is not used,
rather than always calling :c:func:`PyType_GetFlags` which hides implementation
details.