@@ -156,8 +156,9 @@ PyCMethod_GetClass(PyObject *op)
156156/* Methods (the standard built-in methods, that is) */
157157
158158static void
159- meth_dealloc (PyCFunctionObject * m )
159+ meth_dealloc (PyObject * self )
160160{
161+ PyCFunctionObject * m = _PyCFunctionObject_CAST (self );
161162 // The Py_TRASHCAN mechanism requires that we be able to
162163 // call PyObject_GC_UnTrack twice on an object.
163164 PyObject_GC_UnTrack (m );
@@ -175,8 +176,9 @@ meth_dealloc(PyCFunctionObject *m)
175176}
176177
177178static PyObject *
178- meth_reduce (PyCFunctionObject * m , PyObject * Py_UNUSED (ignored ))
179+ meth_reduce (PyObject * self , PyObject * Py_UNUSED (ignored ))
179180{
181+ PyCFunctionObject * m = _PyCFunctionObject_CAST (self );
180182 if (m -> m_self == NULL || PyModule_Check (m -> m_self ))
181183 return PyUnicode_FromString (m -> m_ml -> ml_name );
182184
@@ -185,32 +187,35 @@ meth_reduce(PyCFunctionObject *m, PyObject *Py_UNUSED(ignored))
185187}
186188
187189static PyMethodDef meth_methods [] = {
188- {"__reduce__" , ( PyCFunction ) meth_reduce , METH_NOARGS , NULL },
190+ {"__reduce__" , meth_reduce , METH_NOARGS , NULL },
189191 {NULL , NULL }
190192};
191193
192194static PyObject *
193- meth_get__text_signature__ (PyCFunctionObject * m , void * closure )
195+ meth_get__text_signature__ (PyObject * self , void * closure )
194196{
197+ PyCFunctionObject * m = _PyCFunctionObject_CAST (self );
195198 return _PyType_GetTextSignatureFromInternalDoc (m -> m_ml -> ml_name ,
196199 m -> m_ml -> ml_doc ,
197200 m -> m_ml -> ml_flags );
198201}
199202
7440
200203static PyObject *
201- meth_get__doc__ (PyCFunctionObject * m , void * closure )
204+ meth_get__doc__ (PyObject * self , void * closure )
202205{
206+ PyCFunctionObject * m = _PyCFunctionObject_CAST (self );
203207 return _PyType_GetDocFromInternalDoc (m -> m_ml -> ml_name , m -> m_ml -> ml_doc );
204208}
205209
206210static PyObject *
207- meth_get__name__ (PyCFunctionObject * m , void * closure )
211+ meth_get__name__ (PyObject * self , void * closure )
208212{
213+ PyCFunctionObject * m = _PyCFunctionObject_CAST (self );
209214 return PyUnicode_FromString (m -> m_ml -> ml_name );
210215}
211216
212217static PyObject *
213- meth_get__qualname__ (PyCFunctionObject * m , void * closure )
218+ meth_get__qualname__ (PyObject * self , void * closure )
214219{
215220 /* If __self__ is a module or NULL, return m.__name__
216221 (e.g. len.__qualname__ == 'len')
@@ -220,14 +225,15 @@ meth_get__qualname__(PyCFunctionObject *m, void *closure)
220225
221226 Otherwise return type(m.__self__).__qualname__ + '.' + m.__name__
222227 (e.g. [].append.__qualname__ == 'list.append') */
223- PyObject * type , * type_qualname , * res ;
224228
225- if (m -> m_self == NULL || PyModule_Check (m -> m_self ))
229+ PyCFunctionObject * m = _PyCFunctionObject_CAST (self );
230+ if (m -> m_self == NULL || PyModule_Check (m -> m_self )) {
226231 return PyUnicode_FromString (m -> m_ml -> ml_name );
232+ }
227233
228- type = PyType_Check (m -> m_self ) ? m -> m_self : (PyObject * )Py_TYPE (m -> m_self );
234+ PyObject * type = PyType_Check (m -> m_self ) ? m -> m_self : (PyObject * )Py_TYPE (m -> m_self );
229235
230- type_qualname = PyObject_GetAttr (type , & _Py_ID (__qualname__ ));
236+ PyObject * type_qualname = PyObject_GetAttr (type , & _Py_ID (__qualname__ ));
231237 if (type_qualname == NULL )
232238 return NULL ;
233239
@@ -238,37 +244,38 @@ meth_get__qualname__(PyCFunctionObject *m, void *closure)
238244 return NULL ;
239245 }
240246
241- res = PyUnicode_FromFormat ("%S.%s" , type_qualname , m -> m_ml -> ml_name );
247+ PyObject * res = PyUnicode_FromFormat ("%S.%s" , type_qualname , m -> m_ml -> ml_name );
242248 Py_DECREF (type_qualname );
243249 return res ;
244250}
245251
246252static int
247- meth_traverse (PyCFunctionObject * m , visitproc visit , void * arg )
253+ meth_traverse (PyObject * self , visitproc visit , void * arg )
248254{
255+ PyCFunctionObject * m = _PyCFunctionObject_CAST (self );
249256 Py_VISIT (PyCFunction_GET_CLASS (m ));
250257 Py_VISIT (m -> m_self );
251258 Py_VISIT (m -> m_module );
252259 return 0 ;
253260}
254261<
1E71
/code>
255262static PyObject *
256- meth_get__self__ (PyCFunctionObject * m , void * closure )
263+ meth_get__self__ (PyObject * meth , void * closure )
257264{
258- PyObject * self ;
259-
260- self = PyCFunction_GET_SELF (m );
261- if (self == NULL )
265+ PyCFunctionObject * m = _PyCFunctionObject_CAST (meth );
266+ PyObject * self = PyCFunction_GET_SELF (m );
267+ if (self == NULL ) {
262268 self = Py_None ;
269+ }
263270 return Py_NewRef (self );
264271}
265272
266- static PyGetSetDef meth_getsets [] = {
267- {"__doc__" , ( getter ) meth_get__doc__ , NULL , NULL },
268- {"__name__" , ( getter ) meth_get__name__ , NULL , NULL },
269- {"__qualname__" , ( getter ) meth_get__qualname__ , NULL , NULL },
270- {"__self__" , ( getter ) meth_get__self__ , NULL , NULL },
271- {"__text_signature__" , ( getter ) meth_get__text_signature__ , NULL , NULL },
273+ static PyGetSetDef meth_getsets [] = {
274+ {"__doc__" , meth_get__doc__ , NULL , NULL },
275+ {"__name__" , meth_get__name__ , NULL , NULL },
276+ {"__qualname__" , meth_get__qualname__ , NULL , NULL },
277+ {"__self__" , meth_get__self__ , NULL , NULL },
278+ {"__text_signature__" , meth_get__text_signature__ , NULL , NULL },
272279 {0 }
273280};
274281
@@ -280,15 +287,18 @@ static PyMemberDef meth_members[] = {
280287};
281288
282289static PyObject *
283- meth_repr (PyCFunctionObject * m )
290+ meth_repr (PyObject * self )
284291{
285- if (m -> m_self == NULL || PyModule_Check (m -> m_self ))
292+ PyCFunctionObject * m = _PyCFunctionObject_CAST (self );
293+ if (m -> m_self == NULL || PyModule_Check (m -> m_self )) {
286294 return PyUnicode_FromFormat ("<built-in function %s>" ,
287- m -> m_ml -> ml_name );
295+ m -> m_ml -> ml_name );
296+ }
297+
288298 return PyUnicode_FromFormat ("<built-in method %s of %s object at %p>" ,
289- m -> m_ml -> ml_name ,
290- Py_TYPE (m -> m_self )-> tp_name ,
291- m -> m_self );
299+ m -> m_ml -> ml_name ,
300+ Py_TYPE (m -> m_self )-> tp_name ,
301+ m -> m_self );
292302}
293303
294304static PyObject *
@@ -317,14 +327,15 @@ meth_richcompare(PyObject *self, PyObject *other, int op)
317327}
318328
319329static Py_hash_t
320- meth_hash (PyCFunctionObject * a )
330+ meth_hash (PyObject * self )
321331{
322- Py_hash_t x , y ;
323- x = PyObject_GenericHash (a -> m_self );
324- y = _Py_HashPointer ((void * )(a -> m_ml -> ml_meth ));
332+ PyCFunctionObject * a = _PyCFunctionObject_CAST ( self ) ;
333+ Py_hash_t x = PyObject_GenericHash (a -> m_self );
334+ Py_hash_t y = _Py_HashPointer ((void * )(a -> m_ml -> ml_meth ));
325335 x ^= y ;
326- if (x == -1 )
336+ if (x == -1 ) {
327337 x = -2 ;
338+ }
328339 return x ;
329340}
330341
@@ -334,16 +345,16 @@ PyTypeObject PyCFunction_Type = {
334345 "builtin_function_or_method" ,
335346 sizeof (PyCFunctionObject ),
336347 0 ,
337- ( destructor ) meth_dealloc , /* tp_dealloc */
348+ meth_dealloc , /* tp_dealloc */
338349 offsetof(PyCFunctionObject , vectorcall ), /* tp_vectorcall_offset */
339350 0 , /* tp_getattr */
340351 0 , /* tp_setattr */
341352 0 , /* tp_as_async */
342- ( reprfunc ) meth_repr , /* tp_repr */
353+ meth_repr , /* tp_repr */
343354 0 , /* tp_as_number */
344355 0 , /* tp_as_sequence */
345356 0 , /* tp_as_mapping */
346- ( hashfunc ) meth_hash , /* tp_hash */
357+ meth_hash , /* tp_hash */
347358 cfunction_call , /* tp_call */
348359 0 , /* tp_str */
349360 PyObject_GenericGetAttr , /* tp_getattro */
@@ -352,7 +363,7 @@ PyTypeObject PyCFunction_Type = {
352363 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
353364 Py_TPFLAGS_HAVE_VECTORCALL , /* tp_flags */
354365 0 , /* tp_doc */
355- ( traverseproc ) meth_traverse , /* tp_traverse */
366+ meth_traverse , /* tp_traverse */
356367 0 , /* tp_clear */
357368 meth_richcompare , /* tp_richcompare */
358369 offsetof(PyCFunctionObject , m_weakreflist ), /* tp_weaklistoffset */
0 commit comments