{"record":{"id":"8eba5aa67634e5f3","repo":"huggingface/smolagents","slug":"deletion-of-type-target-name-targets-is-not","errorCode":null,"errorMessage":"Deletion of {type(target).__name__} targets is not supported","messagePattern":"Deletion of (.+?) targets is not supported","errorType":"exception","errorClass":"InterpreterError","httpStatus":null,"severity":"error","filePath":"src/smolagents/local_python_executor.py","lineNumber":1413,"sourceCode":"        authorized_imports: List of authorized imports\n    \"\"\"\n    for target in delete_node.targets:\n        if isinstance(target, ast.Name):\n            # Handle simple variable deletion (del x)\n            if target.id in state:\n                del state[target.id]\n            else:\n                raise InterpreterError(f\"Cannot delete name '{target.id}': name is not defined\")\n        elif isinstance(target, ast.Subscript):\n            # Handle index/key deletion (del x[y])\n            obj = evaluate_ast(target.value, state, static_tools, custom_tools, authorized_imports)\n            index = evaluate_ast(target.slice, state, static_tools, custom_tools, authorized_imports)\n            try:\n                del obj[index]\n            except (TypeError, KeyError, IndexError) as e:\n                raise InterpreterError(f\"Cannot delete index/key: {str(e)}\")\n        else:\n            raise InterpreterError(f\"Deletion of {type(target).__name__} targets is not supported\")\n\n\n@safer_eval\ndef evaluate_ast(\n    expression: ast.AST,\n    state: dict[str, Any],\n    static_tools: dict[str, Callable],\n    custom_tools: dict[str, Callable],\n    authorized_imports: list[str] = BASE_BUILTIN_MODULES,\n):\n    \"\"\"\n    Evaluate an abstract syntax tree using the content of the variables stored in a state and only evaluating a given\n    set of functions.\n\n    This function will recurse through the nodes of the tree provided.\n\n    Args:\n        expression (`ast.AST`):","sourceCodeStart":1395,"sourceCodeEnd":1431,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/local_python_executor.py#L1395-L1431","documentation":"The interpreter only supports del on plain names (del x) and subscripts (del x[i]). Any other target — attribute deletion (del obj.attr), tuple targets (del (a, b)), or starred targets — is unsupported.","triggerScenarios":"del obj.attr, del (a, b), or del a, in some AST shape not Name/Subscript.","commonSituations":"Agent code tries to remove an attribute from an object to clean up; uses tuple deletion; the sandbox being deliberately narrower than CPython's del semantics.","solutions":["For attributes, set obj.attr = None instead of del obj.attr","Delete tuple elements individually: del a; del b","Restructure cleanup to reassignment rather than deletion"],"exampleFix":"# before\ndel obj.temp_attr\n# after\nobj.temp_attr = None","handlingStrategy":"fallback","validationCode":"# in generated code: replace del obj.attr with reassignment\nobj.attr = None","typeGuard":null,"tryCatchPattern":"try:\n    evaluate_python(code, ...)\nexcept InterpreterError as e:\n    if 'targets is not supported' in str(e):\n        # rewrite deletion as reassignment and retry","preventionTips":["Only use del on names and subscripts in sandboxed code","Clean up attributes via assignment to None"],"tags":["python-executor","del","unsupported-syntax","smolagents"],"backgroundTag":"unsupported-del-target","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}