@@ -1278,8 +1278,9 @@ typedef struct {
1278
1278
1279
1279
1280
1280
static void
1281
- lineiter_dealloc (lineiterator * li )
1281
+ lineiter_dealloc (PyObject * self )
1282
1282
{
1283
+ lineiterator * li = (lineiterator * )self ;
1283
1284
Py_DECREF (li -> li_code );
1284
1285
Py_TYPE (li )-> tp_free (li );
1285
1286
}
@@ -1293,8 +1294,9 @@ _source_offset_converter(int *value) {
1293
1294
}
1294
1295
1295
1296
static PyObject *
1296
- lineiter_next (lineiterator * li )
1297
+ lineiter_next (PyObject * self )
1297
1298
{
1299
+ lineiterator * li = (lineiterator * )self ;
1298
1300
PyCodeAddressRange * bounds = & li -> li_line ;
1299
1301
if (!_PyLineTable_NextAddressRange (bounds )) {
1300
1302
return NULL ;
@@ -1318,7 +1320,7 @@ PyTypeObject _PyLineIterator = {
1318
1320
sizeof (lineiterator ), /* tp_basicsize */
1319
1321
0 , /* tp_itemsize */
1320
1322
/* methods */
1321
- ( destructor ) lineiter_dealloc , /* tp_dealloc */
1323
+ lineiter_dealloc , /* tp_dealloc */
1322
1324
0 , /* tp_vectorcall_offset */
1323
1325
0 , /* tp_getattr */
1324
1326
0 , /* tp_setattr */
@@ -1340,7 +1342,7 @@ PyTypeObject _PyLineIterator = {
1340
1342
0 , /* tp_richcompare */
1341
1343
0 , /* tp_weaklistoffset */
1342
1344
PyObject_SelfIter , /* tp_iter */
1343
- ( iternextfunc ) lineiter_next , /* tp_iternext */
1345
+ lineiter_next , /* tp_iternext */
1344
1346
0 , /* tp_methods */
1345
1347
0 , /* tp_members */
1346
1348
0 , /* tp_getset */
@@ -1379,15 +1381,17 @@ typedef struct {
1379
1381
} positionsiterator ;
1380
1382
1381
1383
static void
1382
- positionsiter_dealloc (positionsiterator * pi )
1384
+ positionsiter_dealloc (PyObject * self )
1383
1385
{
1386
+ positionsiterator * pi = (positionsiterator * )self ;
1384
1387
Py_DECREF (pi -> pi_code );
1385
1388
Py_TYPE (pi )-> tp_free (pi );
1386
1389
}
1387
1390
1388
1391
static PyObject *
1389
- positionsiter_next (positionsiterator * pi )
1392
+ positionsiter_next (PyObject * self )
1390
1393
{
1394
+ positionsiterator * pi = (positionsiterator * )self ;
1391
1395
if (pi -> pi_offset >= pi -> pi_range .ar_end ) {
1392
1396
assert (pi -> pi_offset == pi -> pi_range .ar_end );
1393
1397
if (at_end (& pi -> pi_range )) {
@@ -1409,7 +1413,7 @@ PyTypeObject _PyPositionsIterator = {
1409
1413
sizeof (positionsiterator ), /* tp_basicsize */
1410
1414
0 , /* tp_itemsize */
1411
1415
/* methods */
1412
- ( destructor ) positionsiter_dealloc , /* tp_dealloc */
1416
+ positionsiter_dealloc , /* tp_dealloc */
1413
1417
0 , /* tp_vectorcall_offset */
1414
1418
0 , /* tp_getattr */
1415
1419
0 , /* tp_setattr */
@@ -1431,7 +1435,7 @@ PyTypeObject _PyPositionsIterator = {
1431
1435
0 , /* tp_richcompare */
1432
1436
0 , /* tp_weaklistoffset */
1433
1437
PyObject_SelfIter , /* tp_iter */
1434
- ( iternextfunc ) positionsiter_next , /* tp_iternext */
1438
+ positionsiter_next , /* tp_iternext */
1435
1439
0 , /* tp_methods */
1436
1440
0 , /* tp_members */
1437
1441
0 , /* tp_getset */
@@ -1447,8 +1451,9 @@ PyTypeObject _PyPositionsIterator = {
1447
1451
};
1448
1452
1449
1453
static PyObject *
1450
- code_positionsiterator (PyCodeObject * code , PyObject * Py_UNUSED (args ))
1454
+ code_positionsiterator (PyObject * self , PyObject * Py_UNUSED (args ))
1451
1455
{
1456
+ PyCodeObject * code = (PyCodeObject * )self ;
1452
1457
positionsiterator * pi = (positionsiterator * )PyType_GenericAlloc (& _PyPositionsIterator , 0 );
1453
1458
if (pi == NULL ) {
1454
1459
return NULL ;
@@ -1875,16 +1880,18 @@ code_dealloc(PyCodeObject *co)
1875
1880
1876
1881
#ifdef Py_GIL_DISABLED
1877
1882
static int
1878
- code_traverse (PyCodeObject * co , visitproc visit , void * arg )
1883
+ code_traverse (PyObject * self , visitproc visit , void * arg )
1879
1884
{
1885
+ PyCodeObject * co = (PyCodeObject * )self ;
1880
1886
Py_VISIT (co -> co_consts );
1881
1887
return 0 ;
1882
1888
}
1883
1889
#endif
1884
1890
1885
1891
static PyObject *
1886
- code_repr (PyCodeObject * co )
1892
+ code_repr (PyObject * self )
1887
1893
{
1894
+ PyCodeObject * co = (PyCodeObject * )self ;
1888
1895
int lineno ;
1889
1896
if (co -> co_firstlineno != 0 )
1890
1897
lineno = co -> co_firstlineno ;
@@ -1991,8 +1998,9 @@ code_richcompare(PyObject *self, PyObject *other, int op)
1991
1998
}
1992
1999
1993
2000
static Py_hash_t
1994
- code_hash (PyCodeObject * co )
2001
+ code_hash (PyObject * self )
1995
2002
{
2003
+ PyCodeObject * co = (PyCodeObject * )self ;
1996
2004
Py_uhash_t uhash = 20221211 ;
1997
2005
#define SCRAMBLE_IN (H ) do { \
1998
2006
uhash ^= (Py_uhash_t)(H); \
@@ -2053,8 +2061,9 @@ static PyMemberDef code_memberlist[] = {
2053
2061
2054
2062
2055
2063
static PyObject *
2056
- code_getlnotab (PyCodeObject * code , void * closure )
2064
+ code_getlnotab (PyObject * self , void * closure )
2057
2065
{
2066
+ PyCodeObject * code = (PyCodeObject * )self ;
2058
2067
if (PyErr_WarnEx (PyExc_DeprecationWarning ,
2059
2068
"co_lnotab is deprecated, use co_lines instead." ,
2060
2069
1 ) < 0 ) {
@@ -2064,51 +2073,57 @@ code_getlnotab(PyCodeObject *code, void *closure)
2064
2073
}
2065
2074
2066
2075
static PyObject *
2067
- code_getvarnames (PyCodeObject * code , void * closure )
2076
+ code_getvarnames (PyObject * self , void * closure )
2068
2077
{
2078
+ PyCodeObject * code = (PyCodeObject * )self ;
2069
2079
return _PyCode_GetVarnames (code );
2070
2080
}
2071
2081
2072
2082
static PyObject *
2073
- code_getcellvars (PyCodeObject * code , void * closure )
2083
+ code_getcellvars (PyObject * self , void * closure )
2074
2084
{
2085
+ PyCodeObject * code = (PyCodeObject * )self ;
2075
2086
return _PyCode_GetCellvars (code );
2076
2087
}
2077
2088
2078
2089
static PyObject *
2079
- code_getfreevars (PyCodeObject * code , void * closure )
2090
+ code_getfreevars (PyObject * self , void * closure )
2080
2091
{
2092
+ PyCodeObject * code = (PyCodeObject * )self ;
2081
2093
return _PyCode_GetFreevars (code );
2082
2094
}
2083
2095
2084
2096
static PyObject *
2085
- code_getcodeadaptive (PyCodeObject * code , void * closure )
2097
+ code_getcodeadaptive (PyObject * self , void * closure )
2086
2098
{
2099
+ PyCodeObject * code = (PyCodeObject * )self ;
2087
2100
return PyBytes_FromStringAndSize (code -> co_code_adaptive ,
2088
2101
_PyCode_NBYTES (code ));
2089
2102
}
2090
2103
2091
2104
static PyObject *
2092
- code_getcode (PyCodeObject * code , void * closure )
2105
+ code_getcode (PyObject * self , void * closure )
2093
2106
{
2107
+ PyCodeObject * code = (PyCodeObject * )self ;
2094
2108
return _PyCode_GetCode (code );
2095
2109
}
2096
2110
2097
2111
static PyGetSetDef code_getsetlist [] = {
2098
- {"co_lnotab" , ( getter ) code_getlnotab , NULL , NULL },
2099
- {"_co_code_adaptive" , ( getter ) code_getcodeadaptive , NULL , NULL },
2112
+ {"co_lnotab" , code_getlnotab , NULL , NULL },
2113
+ {"_co_code_adaptive" , code_getcodeadaptive , NULL , NULL },
2100
2114
// The following old names are kept for backward compatibility.
2101
- {"co_varnames" , ( getter ) code_getvarnames , NULL , NULL },
2102
- {"co_cellvars" , ( getter ) code_getcellvars , NULL , NULL },
2103
- {"co_freevars" , ( getter ) code_getfreevars , NULL , NULL },
2104
- {"co_code" , ( getter ) code_getcode , NULL , NULL },
2115
+ {"co_varnames" , code_getvarnames , NULL , NULL },
2116
+ {"co_cellvars" , code_getcellvars , NULL , NULL },
2117
+ {"co_freevars" , code_getfreevars , NULL , NULL },
2118
+ {"co_code" , code_getcode , NULL , NULL },
2105
2119
{0 }
2106
2120
};
2107
2121
2108
2122
2109
2123
static PyObject *
2110
- code_sizeof (PyCodeObject * co , PyObject * Py_UNUSED (args ))
2124
+ code_sizeof (PyObject * self , PyObject * Py_UNUSED (args ))
2111
2125
{
2126
+ PyCodeObject * co = (PyCodeObject * )self ;
2112
2127
size_t res = _PyObject_VAR_SIZE (Py_TYPE (co ), Py_SIZE (co ));
2113
2128
_PyCodeObjectExtra * co_extra = (_PyCodeObjectExtra * ) co -> co_extra ;
2114
2129
if (co_extra != NULL ) {
@@ -2119,8 +2134,9 @@ code_sizeof(PyCodeObject *co, PyObject *Py_UNUSED(args))
2119
2134
}
2120
2135
2121
2136
static PyObject *
2122
- code_linesiterator (PyCodeObject * code , PyObject * Py_UNUSED (args ))
2137
+ code_linesiterator (PyObject * self , PyObject * Py_UNUSED (args ))
2123
2138
{
2139
+ PyCodeObject * code = (PyCodeObject * )self ;
2124
2140
return (PyObject * )new_linesiterator (code );
2125
2141
}
2126
2142
@@ -2262,9 +2278,9 @@ code__varname_from_oparg_impl(PyCodeObject *self, int oparg)
2262
2278
/* XXX code objects need to participate in GC? */
2263
2279
2264
2280
static struct PyMethodDef code_methods [] = {
2265
- {"__sizeof__" , ( PyCFunction ) code_sizeof , METH_NOARGS },
2266
- {"co_lines" , ( PyCFunction ) code_linesiterator , METH_NOARGS },
2267
- {"co_positions" , ( PyCFunction ) code_positionsiterator , METH_NOARGS },
2281
+ {"__sizeof__" , code_sizeof , METH_NOARGS },
2282
+ {"co_lines" , code_linesiterator , METH_NOARGS },
2283
+ {"co_positions" , code_positionsiterator , METH_NOARGS },
2268
2284
CODE_REPLACE_METHODDEF
2269
2285
CODE__VARNAME_FROM_OPARG_METHODDEF
2270
2286
{"__replace__" , _PyCFunction_CAST (code_replace ), METH_FASTCALL |METH_KEYWORDS ,
@@ -2283,11 +2299,11 @@ PyTypeObject PyCode_Type = {
2283
2299
0 , /* tp_getattr */
2284
2300
0 , /* tp_setattr */
2285
2301
0 , /* tp_as_async */
2286
- ( reprfunc ) code_repr , /* tp_repr */
2302
+ code_repr , /* tp_repr */
2287
2303
0 , /* tp_as_number */
2288
2304
0 , /* tp_as_sequence */
2289
2305
0 , /* tp_as_mapping */
2290
- ( hashfunc ) code_hash , /* tp_hash */
2306
+ code_hash , /* tp_hash */
2291
2307
0 , /* tp_call */
2292
2308
0 , /* tp_str */
2293
2309
PyObject_GenericGetAttr , /* tp_getattro */
@@ -2300,7 +2316,7 @@ PyTypeObject PyCode_Type = {
2300
2316
#endif
2301
2317
code_new__doc__ , /* tp_doc */
2302
2318
#ifdef Py_GIL_DISABLED
2303
- ( traverseproc ) code_traverse , /* tp_traverse */
2319
+ code_traverse , /* tp_traverse */
2304
2320
#else
2305
2321
0 , /* tp_traverse */
2306
2322
#endif
0 commit comments