Remove monkey patching in IdIterator.next
authorHarmon <Harmon758@gmail.com>
Thu, 28 Jan 2021 20:08:15 +0000 (14:08 -0600)
committerHarmon <Harmon758@gmail.com>
Thu, 28 Jan 2021 20:08:15 +0000 (14:08 -0600)
For models expecting API.parser to be ModelParser

tweepy/cursor.py

index 58df785d255bc09954b382316327f5b6c8be9819..523e3f8ffc086e1e519b26b4779e63e8e650198c 100644 (file)
@@ -131,16 +131,10 @@ class IdIterator(BaseIterator):
         if self.index >= len(self.results) - 1:
             data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kwargs)
 
-            if hasattr(self.method, '__self__'):
-                old_parser = self.method.__self__.parser
-                # Hack for models which expect ModelParser to be set
-                self.method.__self__.parser = ModelParser()
-
             # This is a special invocation that returns the underlying
             # APIMethod class
             model = ModelParser().parse(self.method(create=True), data)
             if hasattr(self.method, '__self__'):
-                self.method.__self__.parser = old_parser
                 result = self.method.__self__.parser.parse(self.method(create=True), data)
             else:
                 result = model