@@ -653,33 +653,58 @@ I_getattr(Iobject *self, char *name) {
653653 return Py_FindMethod (I_methods , (PyObject * )self , name );
654654}
655655
656+ static PyObject *
657+ I_getiter (Iobject * self )
658+ {
659+ PyObject * myreadline = PyObject_GetAttrString ((PyObject * )self ,
660+ "readline" );
661+ PyObject * emptystring = PyString_FromString ("" );
662+ PyObject * iter = NULL ;
663+ if (!myreadline || !emptystring )
664+ goto finally ;
665+
666+ iter = PyCallIter_New (myreadline , emptystring );
667+ finally :
668+ Py_XDECREF (myreadline );
669+ Py_XDECREF (emptystring );
670+ return iter ;
671+ }
672+
673+
656674static char Itype__doc__ [] =
657675"Simple type for treating strings as input file streams"
658676;
659677
660678static PyTypeObject Itype = {
661679 PyObject_HEAD_INIT (NULL )
662- 0 , /*ob_size*/
663- "StringI" , /*tp_name*/
664- sizeof (Iobject ), /*tp_basicsize*/
665- 0 , /*tp_itemsize*/
680+ 0 , /*ob_size*/
681+ "StringI" , /*tp_name*/
682+ sizeof (Iobject ), /*tp_basicsize*/
683+ 0 , /*tp_itemsize*/
666684 /* methods */
667- (destructor )I_dealloc , /*tp_dealloc*/
668- (printfunc )0 , /*tp_print*/
669- (getattrfunc )I_getattr , /*tp_getattr*/
670- (setattrfunc )0 , /*tp_setattr*/
671- (cmpfunc )0 , /*tp_compare*/
672- (reprfunc )0 , /*tp_repr*/
673- 0 , /*tp_as_number*/
674- 0 , /*tp_as_sequence*/
675- 0 , /*tp_as_mapping*/
676- (hashfunc )0 , /*tp_hash*/
677- (ternaryfunc )0 , /*tp_call*/
678- (reprfunc )0 , /*tp_str*/
679-
680- /* Space for future expansion */
681- 0L ,0L ,0L ,0L ,
682- Itype__doc__ /* Documentation string */
685+ (destructor )I_dealloc , /*tp_dealloc*/
686+ (printfunc )0 , /*tp_print*/
687+ (getattrfunc )I_getattr , /*tp_getattr*/
688+ (setattrfunc )0 , /*tp_setattr*/
689+ (cmpfunc )0 , /*tp_compare*/
690+ (reprfunc )0 , /*tp_repr*/
691+ 0 , /*tp_as_number*/
692+ 0 , /*tp_as_sequence*/
693+ 0 , /*tp_as_mapping*/
694+ (hashfunc )0 , /*tp_hash*/
695+ (ternaryfunc )0 , /*tp_call*/
696+ (reprfunc )0 , /*tp_str*/
697+ 0 , /* tp_getattro */
698+ 0 , /* tp_setattro */
699+ 0 , /* tp_as_buffer */
700+ Py_TPFLAGS_DEFAULT , /* tp_flags */
701+ Itype__doc__ , /* tp_doc */
702+ 0 , /* tp_traverse */
703+ 0 , /* tp_clear */
704+ 0 , /* tp_richcompare */
705+ 0 , /* tp_weaklistoffset */
706+ (getiterfunc )I_getiter , /* tp_iter */
707+ 0 , /* tp_iternext */
683708};
684709
685710static PyObject *
0 commit comments