diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-08 01:42:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 01:42:27 +0200 |
commit | 45ec5b99aefa54552947049086e87ec01bc2fc9a (patch) | |
tree | 991c703174190872d806ae18387e69d62ff69c76 /Objects/object.c | |
parent | bpo-40170: Convert PyObject_CheckBuffer() macro to a function (GH-19376) (diff) | |
download | cpython-45ec5b99aefa54552947049086e87ec01bc2fc9a.tar.gz cpython-45ec5b99aefa54552947049086e87ec01bc2fc9a.tar.bz2 cpython-45ec5b99aefa54552947049086e87ec01bc2fc9a.zip |
bpo-40170: PyType_HasFeature() now always calls PyType_GetFlags() (GH-19378)
PyType_HasFeature() now always calls PyType_GetFlags() to hide
implementation details. Previously, it accessed directly the
PyTypeObject.tp_flags member when the limited C API was not used.
Add fast inlined version _PyType_HasFeature() and _PyType_IS_GC()
for object.c and typeobject.c.
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Objects/object.c b/Objects/object.c index 069afc0ac99..ef4ba997de4 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -188,11 +188,11 @@ PyObject_CallFinalizer(PyObject *self) if (tp->tp_finalize == NULL) return; /* tp_finalize should only be called once. */ - if (PyType_IS_GC(tp) && _PyGC_FINALIZED(self)) + if (_PyType_IS_GC(tp) && _PyGC_FINALIZED(self)) return; tp->tp_finalize(self); - if (PyType_IS_GC(tp)) { + if (_PyType_IS_GC(tp)) { _PyGC_SET_FINALIZED(self); } } @@ -229,7 +229,7 @@ PyObject_CallFinalizerFromDealloc(PyObject *self) Py_SET_REFCNT(self, refcnt); _PyObject_ASSERT(self, - (!PyType_IS_GC(Py_TYPE(self)) + (!_PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self))); /* If Py_REF_DEBUG macro is defined, _Py_NewReference() increased _Py_RefTotal, so we need to undo that. */ @@ -1104,7 +1104,7 @@ _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) descr = _PyType_Lookup(tp, name); if (descr != NULL) { Py_INCREF(descr); - if (PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) { + if (_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) { meth_found = 1; } else { f = Py_TYPE(descr)->tp_descr_get; @@ -2177,7 +2177,7 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg, to crash than dumping the traceback. */ void *ptr; PyTypeObject *type = Py_TYPE(obj); - if (PyType_IS_GC(type)) { + if (_PyType_IS_GC(type)) { ptr = (void *)((char *)obj - sizeof(PyGC_Head)); } else { |