@@ -861,39 +861,41 @@ rangeiter_next(PyObject *op)
861861/*[clinic input]
862862@critical_section
863863range_iterator.__length_hint__
864+ self as r: self(type="_PyRangeIterObject *")
864865
865866Private method returning an estimate of len(list(it)).
866867[clinic start generated code]*/
867868
868869static PyObject *
869- range_iterator___length_hint___impl (_PyRangeIterObject * self )
870- /*[clinic end generated code: output=e1cffa4f1e04271b input=ae170413369cd502 ]*/
870+ range_iterator___length_hint___impl (_PyRangeIterObject * r )
871+ /*[clinic end generated code: output=9ba6f22b1fc23dcc input=e3eb311e99d76e43 ]*/
871872{
872- return PyLong_FromLong (self -> len );
873+ return PyLong_FromLong (r -> len );
873874}
874875
875876/*[clinic input]
876877@critical_section
877878range_iterator.__reduce__
879+ self as r: self(type="_PyRangeIterObject *")
878880
879881Return state information for pickling.
880882[clinic start generated code]*/
881883
882884static PyObject *
883- range_iterator___reduce___impl (_PyRangeIterObject * self )
884- /*[clinic end generated code: output=a462cc821bf3c94e input=ec043bf3db63c113 ]*/
885+ range_iterator___reduce___impl (_PyRangeIterObject * r )
886+ /*[clinic end generated code: output=c44d53750c388415 input=75a25b7076dc2c54 ]*/
885887{
886888 PyObject * start = NULL , * stop = NULL , * step = NULL ;
887889 PyObject * range ;
888890
889891 /* create a range object for pickling */
890- start = PyLong_FromLong (self -> start );
892+ start = PyLong_FromLong (r -> start );
891893 if (start == NULL )
892894 goto err ;
893- stop = PyLong_FromLong (self -> start + self -> len * self -> step );
895+ stop = PyLong_FromLong (r -> start + r -> len * r -> step );
894896 if (stop == NULL )
895897 goto err ;
896- step = PyLong_FromLong (self -> step );
898+ step = PyLong_FromLong (r -> step );
897899 if (step == NULL )
898900 goto err ;
899901 range = (PyObject * )make_range_object (& PyRange_Type ,
@@ -913,27 +915,27 @@ range_iterator___reduce___impl(_PyRangeIterObject *self)
913915/*[clinic input]
914916@critical_section
915917range_iterator.__setstate__
916-
918+ self as r: self(type="_PyRangeIterObject *")
917919 state: object
918920 /
919921
920922Set state information for unpickling.
921923[clinic start generated code]*/
922924
923925static PyObject *
924- range_iterator___setstate___impl (_PyRangeIterObject * self , PyObject * state )
925- /*[clinic end generated code: output=8c0cbca5b07a30a3 input=230f74fae1cb5008 ]*/
926+ range_iterator___setstate___impl (_PyRangeIterObject * r , PyObject * state )
927+ /*[clinic end generated code: output=464b3cbafc2e3562 input=c8c84fab2519d200 ]*/
926928{
927929 long index = PyLong_AsLong (state );
928930 if (index == -1 && PyErr_Occurred ())
929931 return NULL ;
930932 /* silently clip the index value */
931933 if (index < 0 )
932934 index = 0 ;
933- else if (index > self -> len )
934- index = self -> len ; /* exhausted iterator */
935- self -> start += index * self -> step ;
936- self -> len -= index ;
935+ else if (index > r -> len )
936+ index = r -> len ; /* exhausted iterator */
937+ r -> start += index * r -> step ;
938+ r -> len -= index ;
937939 Py_RETURN_NONE ;
938940}
939941
@@ -1034,46 +1036,48 @@ fast_range_iter(long start, long stop, long step, long len)
10341036/*[clinic input]
10351037@critical_section
10361038longrange_iterator.__length_hint__
1039+ self as r: self(type="longrangeiterobject *")
10371040
10381041Private method returning an estimate of len(list(it)).
10391042[clinic start generated code]*/
10401043
10411044static PyObject *
1042- longrange_iterator___length_hint___impl (longrangeiterobject * self )
1043- /*[clinic end generated code: output=1890e941c1688fcd input=eef1908ae4759fb2 ]*/
1045+ longrange_iterator___length_hint___impl (longrangeiterobject * r )
1046+ /*[clinic end generated code: output=e1bce24da7e8bfde input=ba94b050d940411e ]*/
10441047{
1045- Py_INCREF (self -> len );
1046- return self -> len ;
1048+ Py_INCREF (r -> len );
1049+ return r -> len ;
10471050}
10481051
10491052/*[clinic input]
10501053@critical_section
10511054longrange_iterator.__reduce__
1055+ self as r: self(type="longrangeiterobject *")
10521056
10531057Return state information for pickling.
10541058[clinic start generated code]*/
10551059
10561060static PyObject *
1057- longrange_iterator___reduce___impl (longrangeiterobject * self )
1058- /*[clinic end generated code: output=6efcfea6587678cd input=21302109df76aac9 ]*/
1061+ longrange_iterator___reduce___impl (longrangeiterobject * r )
1062+ /*[clinic end generated code: output=0077f94ae2a4e99a input=2e8930e897ace086 ]*/
10591063{
10601064 PyObject * product , * stop = NULL ;
10611065 PyObject * range ;
10621066
10631067 /* create a range object for pickling. Must calculate the "stop" value */
1064- product = PyNumber_Multiply (self -> len , self -> step );
1068+ product = PyNumber_Multiply (r -> len , r -> step );
10651069 if (product == NULL )
10661070 return NULL ;
1067- stop = PyNumber_Add (self -> start , product );
1071+ stop = PyNumber_Add (r -> start , product );
10681072 Py_DECREF (product );
10691073 if (stop == NULL )
10701074 return NULL ;
10711075 range = (PyObject * )make_range_object (& PyRange_Type ,
1072- Py_NewRef (self -> start ), stop , Py_NewRef (self -> step ));
1076+ Py_NewRef (r -> start ), stop , Py_NewRef (r -> step ));
10731077 if (range == NULL ) {
1074- Py_DECREF (self -> start );
1078+ Py_DECREF (r -> start );
10751079 Py_DECREF (stop );
1076- Py_DECREF (self -> step );
1080+ Py_DECREF (r -> step );
10771081 return NULL ;
10781082 }
10791083
@@ -1085,17 +1089,16 @@ longrange_iterator___reduce___impl(longrangeiterobject *self)
10851089/*[clinic input]
10861090@critical_section
10871091longrange_iterator.__setstate__
1088-
1092+ self as r: self(type="longrangeiterobject *")
10891093 state: object
10901094 /
10911095
10921096Set state information for unpickling.
10931097[clinic start generated code]*/
10941098
10951099static PyObject *
1096- longrange_iterator___setstate___impl (longrangeiterobject * self ,
1097- PyObject * state )
1098- /*[clinic end generated code: output=0ad8528a4b723cd0 input=7304c65ba48035ea]*/
1100+ longrange_iterator___setstate___impl (longrangeiterobject * r , PyObject * state )
1101+ /*[clinic end generated code: output=870787f0574f0da4 input=8b116de3018de824]*/
10991102{
11001103 if (!PyLong_CheckExact (state )) {
11011104 PyErr_Format (PyExc_TypeError , "state must be an int, not %T" , state );
@@ -1113,27 +1116,27 @@ longrange_iterator___setstate___impl(longrangeiterobject *self,
11131116 state = zero ;
11141117 }
11151118 else {
1116- cmp = PyObject_RichCompareBool (self -> len , state , Py_LT );
1119+ cmp = PyObject_RichCompareBool (r -> len , state , Py_LT );
11171120 if (cmp < 0 )
11181121 return NULL ;
11191122 if (cmp > 0 )
1120- state = self -> len ;
1123+ state = r -> len ;
11211124 }
1122- PyObject * product = PyNumber_Multiply (state , self -> step );
1125+ PyObject * product = PyNumber_Multiply (state , r -> step );
11231126 if (product == NULL )
11241127 return NULL ;
1125- PyObject * new_start = PyNumber_Add (self -> start , product );
1128+ PyObject * new_start = PyNumber_Add (r -> start , product );
11261129 Py_DECREF (product );
11271130 if (new_start == NULL )
11281131 return NULL ;
1129- PyObject * new_len = PyNumber_Subtract (self -> len , state );
1132+ PyObject * new_len = PyNumber_Subtract (r -> len , state );
11301133 if (new_len == NULL ) {
11311134 Py_DECREF (new_start );
11321135 return NULL ;
11331136 }
1134- PyObject * tmp = self -> start ;
1135- self -> start = new_start ;
1136- Py_SETREF (self -> len , new_len );
1137+ PyObject * tmp = r -> start ;
1138+ r -> start = new_start ;
1139+ Py_SETREF (r -> len , new_len );
11371140 Py_DECREF (tmp );
11381141 Py_RETURN_NONE ;
11391142}
0 commit comments