Beispiel #1
0
def makeReraiseExceptionStatement(source_ref):
    # TODO: Remove the statement sequence packaging and have users do it themselves
    # in factory functions instead.

    return StatementsSequence(
        statements=(StatementReraiseException(source_ref=source_ref), ),
        source_ref=source_ref)
Beispiel #2
0
def makeReraiseExceptionStatement(source_ref):
    return StatementsSequence(
        statements = (
            StatementReraiseException(
                source_ref = source_ref
            ),
        ),
        source_ref = source_ref
    )
Beispiel #3
0
def buildRaiseNode(provider, node, source_ref):
    # Raise statements. Under Python2 they may have type, value and traceback
    # attached, for Python3, you can only give type (actually value) and cause.

    if python_version < 300:
        exception_type = buildNode(provider,
                                   node.type,
                                   source_ref,
                                   allow_none=True)
        exception_value = buildNode(provider,
                                    node.inst,
                                    source_ref,
                                    allow_none=True)
        exception_trace = buildNode(provider,
                                    node.tback,
                                    source_ref,
                                    allow_none=True)
        exception_cause = None
    else:
        exception_type = buildNode(provider,
                                   node.exc,
                                   source_ref,
                                   allow_none=True)
        exception_value = None
        exception_trace = None
        exception_cause = buildNode(provider,
                                    node.cause,
                                    source_ref,
                                    allow_none=True)

    if exception_type is None:
        assert exception_value is None
        assert exception_trace is None
        assert exception_cause is None

        result = StatementReraiseException(source_ref=source_ref)
    else:
        result = StatementRaiseException(exception_type=exception_type,
                                         exception_value=exception_value,
                                         exception_trace=exception_trace,
                                         exception_cause=exception_cause,
                                         source_ref=source_ref)

        if exception_cause is not None:
            result.setCompatibleSourceReference(
                source_ref=exception_cause.getCompatibleSourceReference())
        elif exception_trace is not None:
            result.setCompatibleSourceReference(
                source_ref=exception_trace.getCompatibleSourceReference())
        elif exception_value is not None:
            result.setCompatibleSourceReference(
                source_ref=exception_value.getCompatibleSourceReference())
        elif exception_type is not None:
            result.setCompatibleSourceReference(
                source_ref=exception_type.getCompatibleSourceReference())

    return result
def makeReraiseExceptionStatement(source_ref):
    return StatementReraiseException(source_ref=source_ref)