#NEWLINE# def ExceptHook( excType , excValue , traceObject ) : #NEWLINE# #INDENT# import traceback , os #NEWLINE# errorMsg = '\n' . join ( traceback . format_exception ( excType , excValue , excType ) ) #NEWLINE# if ( type ( errorMsg ) == bytes ) : #NEWLINE# #INDENT# errorMsg = errorMsg . decode ( encoding = 'ascii' , errors = 'replace' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# errorMsg = errorMsg . encode ( 'ascii' , errors = 'replace' ) #NEWLINE# errorMsg = errorMsg . decode ( 'ascii' , errors = 'replace' ) #NEWLINE# #UNINDENT# print ( ( ( '\n' + errorMsg ) + '\n' ) )