diff options
author | Victor Stinner <vstinner@python.org> | 2020-07-08 09:02:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 09:02:23 (GMT) |
commit | b26a0db8ea2de3a8a8e4b40e69fc8642c7d7cb68 (patch) | |
tree | eb46d0d5a9c6637eaba6db96a869095d26fade3e /Include/object.h | |
parent | aebc0495572c5bb85d2bd97d27cf93ab038b5a6a (diff) | |
download | cpython-b26a0db8ea2de3a8a8e4b40e69fc8642c7d7cb68.zip cpython-b26a0db8ea2de3a8a8e4b40e69fc8642c7d7cb68.tar.gz cpython-b26a0db8ea2de3a8a8e4b40e69fc8642c7d7cb68.tar.bz2 |
Revert "bpo-40170: PyType_HasFeature() now always calls PyType_GetFlags() (GH-19378)" (GH-21390)
This partially reverts commit 45ec5b99aefa54552947049086e87ec01bc2fc9a.
Diffstat (limited to 'Include/object.h')
-rw-r--r-- | Include/object.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Include/object.h b/Include/object.h index 5375670..10f1d6a 100644 --- a/Include/object.h +++ b/Include/object.h @@ -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) |