]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40170: Use inline _PyType_HasFeature() function (GH-22375)
authorVictor Stinner <vstinner@python.org>
Wed, 23 Sep 2020 12:08:38 +0000 (14:08 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Sep 2020 12:08:38 +0000 (14:08 +0200)
Use _PyType_HasFeature() in the _io module and in structseq
implementation. Replace PyType_HasFeature() opaque function call with
_PyType_HasFeature() inlined function.

Modules/_io/iobase.c
Objects/structseq.c

index a8e55c34799bd5b02728461c0f2755a741930c77..195862df5dc06000384ac4ea320ddabbee47cba1 100644 (file)
@@ -349,8 +349,9 @@ iobase_dealloc(iobase *self)
     if (_PyIOBase_finalize((PyObject *) self) < 0) {
         /* When called from a heap type's dealloc, the type will be
            decref'ed on return (see e.g. subtype_dealloc in typeobject.c). */
-        if (PyType_HasFeature(Py_TYPE(self), Py_TPFLAGS_HEAPTYPE))
+        if (_PyType_HasFeature(Py_TYPE(self), Py_TPFLAGS_HEAPTYPE)) {
             Py_INCREF(Py_TYPE(self));
+        }
         return;
     }
     _PyObject_GC_UNTRACK(self);
index bd20ce3fbdcb942ffd484def1f0210cadf9261c9..8ae8f28cbc580f96be9cc53630b8ce6e7ebe4ed1 100644 (file)
@@ -94,7 +94,7 @@ structseq_dealloc(PyStructSequence *obj)
         Py_XDECREF(obj->ob_item[i]);
     }
     PyObject_GC_Del(obj);
-    if (PyType_GetFlags(tp) & Py_TPFLAGS_HEAPTYPE) {
+    if (_PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE)) {
         Py_DECREF(tp);
     }
 }