mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
28 lines
577 B
Python
28 lines
577 B
Python
import traceback
|
|
|
|
try:
|
|
1 / 0
|
|
except ZeroDivisionError as ex:
|
|
tb = traceback.extract_tb(ex.__traceback__)
|
|
assert len(tb) == 1
|
|
|
|
|
|
try:
|
|
try:
|
|
1 / 0
|
|
except ZeroDivisionError as ex:
|
|
raise KeyError().with_traceback(ex.__traceback__)
|
|
except KeyError as ex2:
|
|
tb = traceback.extract_tb(ex2.__traceback__)
|
|
assert tb[1].line == "1 / 0"
|
|
|
|
|
|
try:
|
|
try:
|
|
1 / 0
|
|
except ZeroDivisionError as ex:
|
|
raise ex.with_traceback(None)
|
|
except ZeroDivisionError as ex2:
|
|
tb = traceback.extract_tb(ex2.__traceback__)
|
|
assert len(tb) == 1
|