[Python-checkins] bpo-40170: Use inline _PyType_HasFeature() function (GH-22375)

Victor Stinner webhook-mailer at python.org
Wed Sep 23 08:08:42 EDT 2020


https://github.com/python/cpython/commit/97d15ae1d8411b49b1fcdc0c67c51849dccce9c9
commit: 97d15ae1d8411b49b1fcdc0c67c51849dccce9c9
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-09-23T14:08:38+02:00
summary:

bpo-40170: Use inline _PyType_HasFeature() function (GH-22375)

Use _PyType_HasFeature() in the _io module and in structseq
implementation. Replace PyType_HasFeature() opaque function call with
_PyType_HasFeature() inlined function.

files:
M Modules/_io/iobase.c
M Objects/structseq.c

diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index a8e55c34799bd..195862df5dc06 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -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);
diff --git a/Objects/structseq.c b/Objects/structseq.c
index bd20ce3fbdcb9..8ae8f28cbc580 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -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);
     }
 }



More information about the Python-checkins mailing list