How to use the nuitka.tree.ReformulationTryFinallyStatements.makeTryFinallyStatement function in Nuitka

To help you get started, we’ve selected a few Nuitka examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nuitka / Nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
value=ExpressionVariableRef(
                    variable=star_dict_variable, source_ref=internal_source_ref
                ),
                source_ref=internal_source_ref,
            ),
            right=makeExpressionBuiltinRef(
                builtin_name="dict", source_ref=internal_source_ref
            ),
            source_ref=internal_source_ref,
        ),
        yes_branch=mapping_case,
        no_branch=dict_case,
        source_ref=internal_source_ref,
    )

    return makeTryFinallyStatement(
        provider=result, tried=tried, final=final, source_ref=internal_source_ref
    )
github Nuitka / Nuitka / nuitka / tree / ReformulationClasses3.py View on Github external
),
        StatementLoop(body=loop_body, source_ref=internal_source_ref),
        StatementReturn(
            expression=ExpressionBuiltinTuple(
                value=ExpressionTempVariableRef(
                    variable=tmp_result_variable, source_ref=internal_source_ref
                ),
                source_ref=internal_source_ref,
            ),
            source_ref=internal_source_ref,
        ),
    )

    result.setBody(
        makeStatementsSequenceFromStatement(
            makeTryFinallyStatement(
                provider=result,
                tried=tried,
                final=final,
                source_ref=internal_source_ref,
            )
        )
    )

    return result
github Nuitka / Nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
final = (
        StatementReleaseVariable(
            variable=called_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=args_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(variable=kw_variable, source_ref=internal_source_ref),
        StatementReleaseVariable(
            variable=star_arg_dict_variable, source_ref=internal_source_ref
        ),
    )

    result.setBody(
        makeStatementsSequenceFromStatement(
            makeTryFinallyStatement(
                provider=result,
                tried=statements,
                final=final,
                source_ref=internal_source_ref,
            )
        )
    )

    return result
github Nuitka / Nuitka / nuitka / tree / ReformulationSequenceCreation.py View on Github external
variable=tmp_result_variable,
            source=makeConstantRefNode(constant=[], source_ref=internal_source_ref),
            source_ref=internal_source_ref,
        ),
        StatementLoop(body=loop_body, source_ref=internal_source_ref),
        StatementReturn(
            expression=ExpressionTempVariableRef(
                variable=tmp_result_variable, source_ref=internal_source_ref
            ),
            source_ref=internal_source_ref,
        ),
    )

    result.setBody(
        makeStatementsSequenceFromStatement(
            makeTryFinallyStatement(
                provider=result,
                tried=tried,
                final=final,
                source_ref=internal_source_ref,
            )
        )
    )

    return result
github Nuitka / Nuitka / nuitka / tree / ReformulationContractionExpressions.py View on Github external
function_body=function_body,
        assign_provider=True,
        for_asyncgen=False,
        source_ref=source_ref,
    )

    statements.append(
        StatementReturn(
            expression=ExpressionTempVariableRef(
                variable=container_tmp, source_ref=source_ref
            ),
            source_ref=source_ref,
        )
    )

    statement = makeTryFinallyStatement(
        provider=function_body,
        tried=statements,
        final=release_statements,
        source_ref=source_ref.atInternal(),
    )

    function_body.setBody(makeStatementsSequenceFromStatement(statement=statement))

    return function_body
github Nuitka / Nuitka / nuitka / tree / ReformulationClasses.py View on Github external
statements = (
            StatementAssignmentVariable(
                variable=tmp_base,
                source=ExpressionSubscriptLookup(
                    subscribed=ExpressionTempVariableRef(
                        variable=tmp_bases, source_ref=source_ref
                    ),
                    subscript=makeConstantRefNode(
                        constant=0, source_ref=source_ref, user_provided=True
                    ),
                    source_ref=source_ref,
                ),
                source_ref=source_ref,
            ),
            makeTryFinallyStatement(
                provider,
                tried=StatementTry(
                    tried=makeStatementsSequenceFromStatement(
                        statement=StatementReturn(
                            expression=ExpressionAttributeLookup(
                                source=ExpressionTempVariableRef(
                                    variable=tmp_base, source_ref=source_ref
                                ),
                                attribute_name="__class__",
                                source_ref=source_ref,
                            ),
                            source_ref=source_ref,
                        )
                    ),
                    except_handler=makeStatementsSequenceFromStatement(
                        statement=StatementReturn(
github Nuitka / Nuitka / nuitka / tree / ReformulationSequenceCreation.py View on Github external
variable=tmp_result_variable,
            source=makeConstantRefNode(constant=set(), source_ref=internal_source_ref),
            source_ref=internal_source_ref,
        ),
        StatementLoop(body=loop_body, source_ref=internal_source_ref),
        StatementReturn(
            expression=ExpressionTempVariableRef(
                variable=tmp_result_variable, source_ref=internal_source_ref
            ),
            source_ref=internal_source_ref,
        ),
    )

    result.setBody(
        makeStatementsSequenceFromStatement(
            makeTryFinallyStatement(
                provider=result,
                tried=tried,
                final=final,
                source_ref=internal_source_ref,
            )
        )
    )

    return result
github Nuitka / Nuitka / nuitka / tree / ReformulationWithStatements.py View on Github external
variable=tmp_indicator_variable, source_ref=source_ref
                    ),
                    right=makeConstantRefNode(constant=True, source_ref=source_ref),
                    source_ref=source_ref,
                ),
                yes_branch=StatementExpressionOnly(
                    expression=exit_value_no_exception, source_ref=source_ref
                ),
                no_branch=None,
                source_ref=source_ref,
            ),
            source_ref=source_ref,
        )
    ]

    return makeTryFinallyStatement(
        provider=provider,
        tried=statements,
        final=(
            StatementReleaseVariable(
                variable=tmp_source_variable, source_ref=with_exit_source_ref
            ),
            StatementReleaseVariable(
                variable=tmp_enter_variable, source_ref=with_exit_source_ref
            ),
            StatementReleaseVariable(
                variable=tmp_exit_variable, source_ref=with_exit_source_ref
            ),
            StatementReleaseVariable(
                variable=tmp_indicator_variable, source_ref=with_exit_source_ref
            ),
        ),
github Nuitka / Nuitka / nuitka / tree / ReformulationForLoopStatements.py View on Github external
iter_source = ExpressionYieldFromWaitable(
            expression = ExpressionAsyncIter(
                value      = source,
                source_ref = source.getSourceReference()
            ),
            source_ref = source.getSourceReference()
        )

    statements += [
        # First create the iterator and store it.
        StatementAssignmentVariable(
            variable   = tmp_iter_variable,
            source     = iter_source,
            source_ref = source_ref
        ),
        makeTryFinallyStatement(
            provider   = provider,
            tried      = StatementLoop(
                body       = loop_body,
                source_ref = source_ref
            ),
            final      = StatementsSequence(
                statements = cleanup_statements,
                source_ref = source_ref
            ),
            source_ref = source_ref
        )
    ]

    if else_block is not None:
        statements += [
            makeStatementConditional(
github Nuitka / Nuitka / nuitka / tree / ComplexCallHelperFunctions.py View on Github external
final = (
        StatementReleaseVariable(
            variable=tmp_dict_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_iter_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_keys_variable, source_ref=internal_source_ref
        ),
        StatementReleaseVariable(
            variable=tmp_key_variable, source_ref=internal_source_ref
        ),
    )

    return makeTryFinallyStatement(
        provider=result, tried=tried, final=final, source_ref=internal_source_ref
    )