aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/runtime_py3/test/traceback/crash.py
diff options
context:
space:
mode:
authornkozlovskiy <nmk@ydb.tech>2023-09-29 12:24:06 +0300
committernkozlovskiy <nmk@ydb.tech>2023-09-29 12:41:34 +0300
commite0e3e1717e3d33762ce61950504f9637a6e669ed (patch)
treebca3ff6939b10ed60c3d5c12439963a1146b9711 /library/python/runtime_py3/test/traceback/crash.py
parent38f2c5852db84c7b4d83adfcb009eb61541d1ccd (diff)
downloadydb-e0e3e1717e3d33762ce61950504f9637a6e669ed.tar.gz
add ydb deps
Diffstat (limited to 'library/python/runtime_py3/test/traceback/crash.py')
-rw-r--r--library/python/runtime_py3/test/traceback/crash.py42
1 files changed, 42 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..dfd316d4c6
--- /dev/null
+++ b/library/python/runtime_py3/test/traceback/crash.py
@@ -0,0 +1,42 @@
+import argparse
+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(f"Kaboom! I'm dead: {x}")
+
+
+def main():
+ hooks = {
+ "default": lambda: sys.excepthook,
+ "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()