Refactor ExceptHook to get rid of archaic string usage and restore reporting to stderr.

This commit is contained in:
Scott Kitterman committed 2018-02-14 07:21:22 -05:00
1 parent 19ac561822
commit 92923fdbc4
1 file changed
+4 -5
+4 -5
View File
@@ -51,7 +51,6 @@ def drop_privileges(milterconfig):
old_umask = os.umask(milterconfig.get('UMask'))
#################
# FIXME - still uses string, refactor
class ExceptHook:
def __init__(self, useSyslog = 1, useStderr = 0):
self.useSyslog = useSyslog
@@ -59,14 +58,14 @@ class ExceptHook:
def __call__(self, etype, evalue, etb):
import traceback
import string
import sys
tb = traceback.format_exception(*(etype, evalue, etb))
tb = map(string.rstrip, tb)
tb = string.join(tb, '\n')
for line in string.split(tb, '\n'):
for line in tb:
if self.useSyslog:
import syslog
syslog.syslog(line)
if self.useStderr:
sys.stderr.write(line)
####################