From 10e5c641ecd45d896d25b0511438c9a9ce3c59e4 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Tue, 23 Oct 2018 13:32:28 -0400 Subject: Make iterators Python3-compatible In Python3, the iterator protocol uses a method named __next__(), not next(). (For compatibility with Python 2.6, we still need to support both though.) Ensure all iterator objects support the Python3 protocol. Signed-off-by: Zane Bitter --- paste/httpserver.py | 1 + paste/wsgilib.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/paste/httpserver.py b/paste/httpserver.py index 11489b0..8bacfbc 100755 --- a/paste/httpserver.py +++ b/paste/httpserver.py @@ -513,6 +513,7 @@ class LimitedLengthFile(object): if self.length - self._consumed <= 0: raise StopIteration return self.readline() + __next__ = next ## Optional methods ## diff --git a/paste/wsgilib.py b/paste/wsgilib.py index d5862e7..7993f29 100644 --- a/paste/wsgilib.py +++ b/paste/wsgilib.py @@ -126,6 +126,7 @@ class chained_app_iters(object): except StopIteration: self.chained.pop(0) return self.next() + __next__ = next def close(self): self._closed = True @@ -216,6 +217,7 @@ class _wrap_app_iter(object): except: self.error_callback(sys.exc_info()) raise + __next__ = next def catch_errors_app(application, environ, start_response, error_callback_app, ok_callback=None, catch=Exception): @@ -278,6 +280,7 @@ class _wrap_app_iter_app(object): self.close = new_app_iterable.close self.next = app_iter.next return self.next() + __next__ = next def raw_interactive(application, path='', raise_on_wsgi_error=False, **environ): -- cgit v1.2.1