Skip to content

Commit

Permalink
Catch exceptions trying to report exceptions in ptraceback().
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akkana committed Dec 30, 2017
1 parent 90e2376 commit bafd305
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions feedmeparser.py
Expand Up @@ -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
Expand Down

0 comments on commit bafd305

Please sign in to comment.