MCPcopy Index your code
hub / github.com/ipython/ipython / _eval_node_name

Function _eval_node_name

IPython/core/guarded_eval.py:1445–1463  ·  view source on GitHub ↗
(node_id: str, context: EvaluationContext)

Source from the content-addressed store, hash-verified

1443
1444
1445def _eval_node_name(node_id: str, context: EvaluationContext):
1446 policy = get_policy(context)
1447 if node_id in context.transient_locals:
1448 return context.transient_locals[node_id]
1449 if policy.allow_locals_access and node_id in context.locals:
1450 return context.locals[node_id]
1451 if policy.allow_globals_access and node_id in context.globals:
1452 return context.globals[node_id]
1453 if policy.allow_builtins_access and hasattr(builtins, node_id):
1454 # note: do not use __builtins__, it is implementation detail of cPython
1455 return getattr(builtins, node_id)
1456 if policy.allow_auto_import and context.auto_import:
1457 return context.auto_import(node_id)
1458 if not policy.allow_globals_access and not policy.allow_locals_access:
1459 raise GuardRejection(
1460 f"Namespace access not allowed in {context.evaluation} mode"
1461 )
1462 else:
1463 raise NameError(f"{node_id} not found in locals, globals, nor builtins")
1464
1465
1466def _eval_or_create_duck(duck_type, context: EvaluationContext):

Callers 2

eval_nodeFunction · 0.85
_eval_annotationFunction · 0.85

Calls 2

get_policyFunction · 0.85
GuardRejectionClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…