diff options
-rw-r--r-- | wsgitools/middlewares.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/wsgitools/middlewares.py b/wsgitools/middlewares.py index 9792089..804d474 100644 --- a/wsgitools/middlewares.py +++ b/wsgitools/middlewares.py @@ -17,6 +17,13 @@ except NameError: def next(iterator): return iterator.next() +if sys.version_info[0] >= 3: + def exc_info_for_raise(exc_info): + return exc_info[0](exc_info[1]).with_traceback(exc_info[2]) +else: + def exc_info_for_raise(exc_info): + return exc_info[0], exc_info[1], exc_info[2] + from wsgitools.filters import CloseableList, CloseableIterator from wsgitools.authentication import AuthenticationRequired, \ ProtocolViolation, AuthenticationMiddleware @@ -79,7 +86,7 @@ class NoWriteCallableMiddleware: try: if sio.tell() > 0 or gotiterdata: assert exc_info is not None - raise exc_info[0], exc_info[1], exc_info[2] + raise exc_info_for_raise(exc_info) finally: exc_info = None assert isinstance(status, str) @@ -148,7 +155,7 @@ class ContentLengthMiddleware: try: if gotdata: assert exc_info is not None - raise exc_info[0], exc_info[1], exc_info[2] + raise exc_info_for_raise(exc_info) finally: exc_info = None assert isinstance(status, str) @@ -281,7 +288,7 @@ class CachingMiddleware: try: if cache_object[3]: assert exc_info is not None - raise exc_info[0], exc_info[1], exc_info[2] + raise exc_info_for_raise(exc_info) finally: exc_info = None assert isinstance(status, str) |