{ } Raw JSON

bundles / IPython 9.13.0 / IPython / core / guarded_eval / eval_node

function

IPython.core.guarded_eval:eval_node

source: /IPython/core/guarded_eval.py :765

Signature

def   eval_node ( node : Union[ast.AST, None] context : EvaluationContext )

Summary

Evaluate AST node in provided context.

Extended Summary

Applies evaluation restrictions defined in the context. Currently does not support evaluation of functions with keyword arguments.

Does not evaluate actions that always have side effects:

  • class definitions (class sth: ...)

  • function definitions (def sth: ...)

  • variable assignments (x = 1)

  • augmented assignments (x += 1)

  • deletions (del x)

Does not evaluate operations which do not return values:

  • assertions (assert x)

  • pass (pass)

  • imports (import x)

  • control flow:

    • conditionals (if x:) except for ternary IfExp (a if x else b)

    • loops (for and while)

    • exception handling

The purpose of this function is to guard against unwanted side-effects; it does not give guarantees on protection from malicious code execution.

Aliases

  • IPython.core.guarded_eval.eval_node