From 1966bf28d296e6b0d4e08c8f140ed12fc2960f60 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Mon, 18 Jul 2011 15:19:39 +0200 Subject: adapt exc_info handling for python 3 --- wsgitools/scgi/asynchronous.py | 9 ++++++++- wsgitools/scgi/forkpool.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'wsgitools') diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py index 82dec02..75f1ff0 100644 --- a/wsgitools/scgi/asynchronous.py +++ b/wsgitools/scgi/asynchronous.py @@ -11,6 +11,13 @@ except ImportError: import StringIO as io import errno +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] + class SCGIConnection(asyncore.dispatcher): """SCGI connection class used by L{SCGIServer}.""" # connection states @@ -143,7 +150,7 @@ class SCGIConnection(asyncore.dispatcher): if exc_info: if self.outheaders == True: try: - raise exc_info[0], exc_info[1], exc_info[2] + raise exc_info_for_raise(exc_info) finally: exc_info = None assert self.outheaders != True # unsent diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py index 252c455..b090a54 100644 --- a/wsgitools/scgi/forkpool.py +++ b/wsgitools/scgi/forkpool.py @@ -12,6 +12,13 @@ import sys import errno import signal +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] + class SocketFileWrapper: """Wraps a socket to a wsgi-compliant file-like object.""" def __init__(self, sock, toread): @@ -396,7 +403,7 @@ class SCGIServer: def start_response(status, headers, exc_info=None): if exc_info and response_head[0]: try: - raise exc_info[0], exc_info[1], exc_info[2] + raise exc_info_for_raise(exc_info) finally: exc_info = None assert not response_head[0] # unset or not sent -- cgit v1.2.3