import sys try: raise SyntaxError("msg", (b"bytes_filename", 123, 0, "text")) except: sys.excepthook(*sys.exc_info())