From bafd3050611a7d831cf047227c6d0660fd101c8d Mon Sep 17 00:00:00 2001 From: Akkana Peck Date: Sat, 30 Dec 2017 13:33:36 -0700 Subject: [PATCH] Catch exceptions trying to report exceptions in ptraceback(). Python3 seems ridiculously sensitive to charset errors and it's super hard to guard against crashing because python3 has a hissy fit and doesn't want to print a traceback. --- feedmeparser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/feedmeparser.py b/feedmeparser.py index 312ee08..e509e53 100755 --- a/feedmeparser.py +++ b/feedmeparser.py @@ -27,8 +27,12 @@ # This doesn't work reliably either: # TypeError: unorderable types: int() < traceback() in the print line. def ptraceback(): - ex_type, ex, tb = sys.exc_info() - print(str(traceback.format_exc(tb)), file=sys.stderr) + try: + ex_type, ex, tb = sys.exc_info() + print(str(traceback.format_exc(tb)), file=sys.stderr) + except: + print("******** Yikes! Exception trying to print traceback", + file=sys.stderr) # XXX # This doesn't work any more, in the Python 3 world, because everything