]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46417: Use _PyType_CAST() in Python directory (GH-30769)
authorVictor Stinner <vstinner@python.org>
Fri, 21 Jan 2022 22:30:17 +0000 (23:30 +0100)
committerGitHub <noreply@github.com>
Fri, 21 Jan 2022 22:30:17 +0000 (23:30 +0100)
Python/bltinmodule.c
Python/specialize.c

index ef1b2bb9cf6449c95cd29c047d3f1401b566d3f6..ecd8be1af6f2dd5711f61aa500231c0cf5373a14 100644 (file)
@@ -536,7 +536,7 @@ static PyObject *
 filter_vectorcall(PyObject *type, PyObject * const*args,
                 size_t nargsf, PyObject *kwnames)
 {
-    PyTypeObject *tp = (PyTypeObject *)type;
+    PyTypeObject *tp = _PyType_CAST(type);
     if (tp == &PyFilter_Type && !_PyArg_NoKwnames("filter", kwnames)) {
         return NULL;
     }
@@ -1251,7 +1251,7 @@ static PyObject *
 map_vectorcall(PyObject *type, PyObject * const*args,
                 size_t nargsf, PyObject *kwnames)
 {
-    PyTypeObject *tp = (PyTypeObject *)type;
+    PyTypeObject *tp = _PyType_CAST(type);
     if (tp == &PyMap_Type && !_PyArg_NoKwnames("map", kwnames)) {
         return NULL;
     }
index e32986ad9d61ae07e30b784e520be34c97a7ffe2..8daeaa6cb2f51c65f54cc800f537f68cf5098dbe 100644 (file)
@@ -1339,8 +1339,7 @@ specialize_class_call(
     PyObject *callable, _Py_CODEUNIT *instr,
     int nargs, SpecializedCacheEntry *cache)
 {
-    assert(PyType_Check(callable));
-    PyTypeObject *tp = (PyTypeObject *)callable;
+    PyTypeObject *tp = _PyType_CAST(callable);
     if (_Py_OPCODE(instr[-1]) == PRECALL_METHOD) {
         SPECIALIZATION_FAIL(CALL_NO_KW, SPEC_FAIL_METHOD_CALL_CLASS);
         return -1;