From e76fe7ce0a94bfe6356fe2af259a75fc0790a3fd Mon Sep 17 00:00:00 2001 From: pjenvey Date: Fri, 11 Aug 2006 03:56:27 +0000 Subject: o catch_errors_app and _wrap_app_iter_app were not in sync with the exception catch_errors_app was specified to catch, causing the wrapper to consume all exceptions o avoid allowing _wrap_app_iter_app to close() its wrapped iter twice in certain situations --- paste/wsgilib.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'paste/wsgilib.py') diff --git a/paste/wsgilib.py b/paste/wsgilib.py index 97ce27f..7f72b89 100644 --- a/paste/wsgilib.py +++ b/paste/wsgilib.py @@ -215,18 +215,19 @@ def catch_errors_app(application, environ, start_response, error_callback_app, else: return _wrap_app_iter_app( environ, start_response, app_iter, - error_callback_app, ok_callback) + error_callback_app, ok_callback, catch=catch) class _wrap_app_iter_app(object): def __init__(self, environ, start_response, app_iterable, - error_callback_app, ok_callback): + error_callback_app, ok_callback, catch=Exception): self.environ = environ self.start_response = start_response self.app_iterable = app_iterable self.app_iter = iter(app_iterable) self.error_callback_app = error_callback_app self.ok_callback = ok_callback + self.catch = catch if hasattr(self.app_iterable, 'close'): self.close = self.app_iterable.close @@ -240,7 +241,7 @@ class _wrap_app_iter_app(object): if self.ok_callback: self.ok_callback() raise - except: + except self.catch: if hasattr(self.app_iterable, 'close'): try: self.app_iterable.close() @@ -252,6 +253,8 @@ class _wrap_app_iter_app(object): app_iter = iter(new_app_iterable) if hasattr(new_app_iterable, 'close'): self.close = new_app_iterable.close + else: + del self.close self.next = app_iter.next return self.next() -- cgit v1.2.1