@@ -626,14 +626,22 @@ static PyMemberDef StopIteration_members[] = {
626
626
{NULL } /* Sentinel */
627
627
};
628
628
629
+ static inline PyStopIterationObject *
630
+ _PyStopIteration_CAST (PyObject * self )
631
+ {
632
+ assert (PyObject_TypeCheck (self , (PyTypeObject * )PyExc_StopIteration ));
633
+ return (PyStopIterationObject * )self ;
634
+ }
635
+
629
636
static int
630
- StopIteration_init (PyStopIterationObject * self , PyObject * args , PyObject * kwds )
637
+ StopIteration_init (PyObject * op , PyObject * args , PyObject * kwds )
631
638
{
632
639
Py_ssize_t size = PyTuple_GET_SIZE (args );
633
640
PyObject * value ;
634
641
635
- if (BaseException_init (( PyBaseExceptionObject * ) self , args , kwds ) == -1 )
642
+ if (BaseException_init (op , args , kwds ) == -1 )
636
643
return -1 ;
644
+ PyStopIterationObject * self = _PyStopIteration_CAST (op );
637
645
Py_CLEAR (self -> value );
638
646
if (size > 0 )
639
647
value = PyTuple_GET_ITEM (args , 0 );
@@ -644,25 +652,27 @@ StopIteration_init(PyStopIterationObject *self, PyObject *args, PyObject *kwds)
644
652
}
645
653
646
654
static int
647
- StopIteration_clear (PyStopIterationObject * self )
655
+ StopIteration_clear (PyObject * op )
648
656
{
657
+ PyStopIterationObject * self = _PyStopIteration_CAST (op );
649
658
Py_CLEAR (self -> value );
650
- return BaseException_clear (( PyBaseExceptionObject * ) self );
659
+ return BaseException_clear (op );
651
660
}
652
661
653
662
static void
654
- StopIteration_dealloc (PyStopIterationObject * self )
663
+ StopIteration_dealloc (PyObject * self )
655
664
{
656
665
PyObject_GC_UnTrack (self );
657
- StopIteration_clear (self );
658
- Py_TYPE (self )-> tp_free (( PyObject * ) self );
666
+ ( void ) StopIteration_clear (self );
667
+ Py_TYPE (self )-> tp_free (self );
659
668
}
660
669
661
670
static int
662
- StopIteration_traverse (PyStopIterationObject * self , visitproc visit , void * arg )
671
+ StopIteration_traverse (PyObject * op , visitproc visit , void * arg )
663
672
{
673
+ PyStopIterationObject * self = _PyStopIteration_CAST (op );
664
674
Py_VISIT (self -> value );
665
- return BaseException_traverse (( PyBaseExceptionObject * ) self , visit , arg );
675
+ return BaseException_traverse (op , visit , arg );
666
676
}
667
677
668
678
ComplexExtendsException (PyExc_Exception , StopIteration , StopIteration ,
0 commit comments