[Python-checkins] bpo-46417: Use _PyType_CAST() in Python directory (GH-30769)

vstinner webhook-mailer at python.org
Fri Jan 21 17:30:28 EST 2022


https://github.com/python/cpython/commit/7835cbf949c413a746324721a352cc72670a8a36
commit: 7835cbf949c413a746324721a352cc72670a8a36
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-01-21T23:30:17+01:00
summary:

bpo-46417: Use _PyType_CAST() in Python directory (GH-30769)

files:
M Python/bltinmodule.c
M Python/specialize.c

diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index ef1b2bb9cf644..ecd8be1af6f2d 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -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;
     }
diff --git a/Python/specialize.c b/Python/specialize.c
index e32986ad9d61a..8daeaa6cb2f51 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -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;



More information about the Python-checkins mailing list