Skip to content

_testinternalcapi.optimize_cfg returns incorrect exception handler labels #115420

Closed
@iritkatriel

Description

@iritkatriel
    def test_except_handler_label(self):
        #
        insts = [
            ('SETUP_FINALLY', handler := self.Label(), 10),
            ('POP_BLOCK', 0, -1),
            ('RETURN_CONST', 1, 11),
            handler,
            ('RETURN_CONST', 2, 12),
        ]
        expected_insts = [
            ('SETUP_FINALLY', handler := self.Label(), 10),
            ('RETURN_CONST', 1, 11),
            handler,
            ('RETURN_CONST', 2, 12),
        ]
        self.cfg_optimization_test(insts, expected_insts, consts=list(range(5)))

This test fails because the code returns with SETUP_FINALLY uninitialized.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions