Preserve traceback for errors in log wrapper

This commit is contained in:
Aldo Cortesi 2015-06-27 10:34:56 +12:00
parent 09d76e1758
commit 61679acf56
2 changed files with 14 additions and 5 deletions

View File

@ -53,7 +53,7 @@ class Log(object):
] ]
) )
if exc_value: if exc_value:
raise exc_value raise exc_type, exc_value, traceback
def suppress(self): def suppress(self):
self.suppressed = True self.suppressed = True

View File

@ -29,7 +29,6 @@ class PathodError(Exception):
class SSLOptions(object): class SSLOptions(object):
def __init__( def __init__(
self, self,
confdir=CONFDIR, confdir=CONFDIR,
@ -69,7 +68,15 @@ class PathodHandler(tcp.BaseHandler):
wbufsize = 0 wbufsize = 0
sni = None sni = None
def __init__(self, connection, address, server, logfp, settings, http2_framedump=False): def __init__(
self,
connection,
address,
server,
logfp,
settings,
http2_framedump=False
):
tcp.BaseHandler.__init__(self, connection, address, server) tcp.BaseHandler.__init__(self, connection, address, server)
self.logfp = logfp self.logfp = logfp
self.settings = copy.copy(settings) self.settings = copy.copy(settings)
@ -418,7 +425,9 @@ class PathodHandler(tcp.BaseHandler):
alp = self.get_alpn_proto_negotiated() alp = self.get_alpn_proto_negotiated()
if alp == http2.HTTP2Protocol.ALPN_PROTO_H2: if alp == http2.HTTP2Protocol.ALPN_PROTO_H2:
self.protocol = http2.HTTP2Protocol(self, is_server=True, dump_frames=self.http2_framedump) self.protocol = http2.HTTP2Protocol(
self, is_server=True, dump_frames=self.http2_framedump
)
self.use_http2 = True self.use_http2 = True
# if not self.protocol: # if not self.protocol:
@ -514,7 +523,7 @@ class Pathod(tcp.TCPServer):
def check_policy(self, req, settings): def check_policy(self, req, settings):
""" """
A policy check that verifies the request size is withing limits. A policy check that verifies the request size is within limits.
""" """
if self.nocraft: if self.nocraft:
return "Crafting disabled.", None return "Crafting disabled.", None