diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/python/runtime_py3/test/traceback/crash.py | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/python/runtime_py3/test/traceback/crash.py')
-rw-r--r-- | library/python/runtime_py3/test/traceback/crash.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/library/python/runtime_py3/test/traceback/crash.py b/library/python/runtime_py3/test/traceback/crash.py new file mode 100644 index 0000000000..b5e36b3dd4 --- /dev/null +++ b/library/python/runtime_py3/test/traceback/crash.py @@ -0,0 +1,44 @@ +import argparse +import cgitb +import sys +import time + +from IPython.core import ultratb + +from .mod import modfunc + + +def one(): + modfunc(two) # aaa + + +def two(): + three(42) + + +def three(x): + raise RuntimeError('Kaboom! I\'m dead: {}'.format(x)) + + +def main(): + hooks = { + 'default': lambda: sys.excepthook, + 'cgitb': lambda: cgitb.Hook(format='text'), + 'ultratb_color': lambda: ultratb.ColorTB(ostream=sys.stderr), + 'ultratb_verbose': lambda: ultratb.VerboseTB(ostream=sys.stderr), + } + + parser = argparse.ArgumentParser() + parser.add_argument('hook', choices=sorted(hooks), default='default') + + args = parser.parse_args() + + sys.excepthook = hooks[args.hook]() + + print('__name__ =', __name__) + print('__file__ =', __file__) + + time.time = lambda: 1531996624.0 # Freeze time + sys.executable = '<traceback test>' + + one() |