作为一些WSGI中间件的一部分,我想编写一个包装迭代器的python类,以在迭代器上实现关闭方法。当我尝试使用旧式类时,它工作正常,但当我使用新式类时,它会抛出TypeError。我需要做什么才能让它与新式类一起工作?例子:classIteratorWrapper1:def__init__(self,otheriter):self._iterator=otheriterself.next=otheriter.nextdef__iter__(self):returnselfdefclose(self):ifgetattr(self._iterator,'close',None)isnot