MCPcopy Index your code
hub / github.com/python/mypy / insert_exception_handling

Function insert_exception_handling

mypyc/transform/exceptions.py:42–54  ·  view source on GitHub ↗
(ir: FuncIR, strict_traceback_checks: bool)

Source from the content-addressed store, hash-verified

40
41
42def insert_exception_handling(ir: FuncIR, strict_traceback_checks: bool) -> None:
43 # Generate error block if any ops may raise an exception. If an op
44 # fails without its own error handler, we'll branch to this
45 # block. The block just returns an error value.
46 error_label: BasicBlock | None = None
47 for block in ir.blocks:
48 adjust_error_kinds(block)
49 if error_label is None and any(op.can_raise() for op in block.ops):
50 error_label = add_default_handler_block(ir)
51 if error_label:
52 ir.blocks = split_blocks_at_errors(
53 ir.blocks, error_label, ir.traceback_name, strict_traceback_checks
54 )
55
56
57def add_default_handler_block(ir: FuncIR) -> BasicBlock:

Callers 3

run_caseMethod · 0.90
run_caseMethod · 0.90
compile_scc_to_irFunction · 0.90

Calls 5

adjust_error_kindsFunction · 0.85
anyFunction · 0.85
split_blocks_at_errorsFunction · 0.85
can_raiseMethod · 0.45

Tested by 2

run_caseMethod · 0.72
run_caseMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…