(state: State, data: ReadBuffer)
| 779 | |
| 780 | |
| 781 | def read_try_stmt(state: State, data: ReadBuffer) -> TryStmt: |
| 782 | body = read_block(state, data) |
| 783 | num_handlers = read_int(data) |
| 784 | |
| 785 | types_list: list[Expression | None] = [] |
| 786 | for _ in range(num_handlers): |
| 787 | has_type = read_bool(data) |
| 788 | if has_type: |
| 789 | exc_type = read_expression(state, data) |
| 790 | types_list.append(exc_type) |
| 791 | else: |
| 792 | types_list.append(None) |
| 793 | |
| 794 | vars_list: list[NameExpr | None] = [] |
| 795 | for _ in range(num_handlers): |
| 796 | has_name = read_bool(data) |
| 797 | if has_name: |
| 798 | var_name = read_str(data) |
| 799 | var_expr = NameExpr(var_name) |
| 800 | read_loc(data, var_expr) |
| 801 | vars_list.append(var_expr) |
| 802 | else: |
| 803 | vars_list.append(None) |
| 804 | |
| 805 | handlers = [] |
| 806 | for _ in range(num_handlers): |
| 807 | handler_body = read_block(state, data) |
| 808 | handlers.append(handler_body) |
| 809 | |
| 810 | has_else = read_bool(data) |
| 811 | if has_else: |
| 812 | else_body = read_block(state, data) |
| 813 | else: |
| 814 | else_body = None |
| 815 | |
| 816 | has_finally = read_bool(data) |
| 817 | if has_finally: |
| 818 | finally_body = read_block(state, data) |
| 819 | else: |
| 820 | finally_body = None |
| 821 | |
| 822 | # except* (Python 3.11+) |
| 823 | is_star = read_bool(data) |
| 824 | |
| 825 | stmt = TryStmt(body, vars_list, types_list, handlers, else_body, finally_body) |
| 826 | stmt.is_star = is_star |
| 827 | read_loc(data, stmt) |
| 828 | expect_end_tag(data) |
| 829 | return stmt |
| 830 | |
| 831 | |
| 832 | def read_type(state: State, data: ReadBuffer) -> Type: |
no test coverage detected
searching dependent graphs…