From f808ccc46421b4818c570071c115c1feb2cdf61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Mon, 15 Jul 2024 20:00:02 -0400 Subject: [PATCH] BF: Fix attempting to delete frame local symbol table variable Fix attempting to delete frame local symbol table variable: starting Python 3.13 attempting to delete local variables is not allowed. Fixes: ``` > del values['self'] E TypeError: cannot remove variables from FrameLocalsProxy ../../BUILDROOT/usr/lib64/python3.13/site-packages/dipy/workflows/multi_io.py:177: TypeError ``` Documentation: https://docs.python.org/3.13/whatsnew/3.13.html#defined-mutation-semantics-for-locals https://peps.python.org/pep-0667/ --- dipy/workflows/multi_io.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dipy/workflows/multi_io.py b/dipy/workflows/multi_io.py index eca1aa5d99..12e5d6c391 100644 --- a/dipy/workflows/multi_io.py +++ b/dipy/workflows/multi_io.py @@ -175,9 +175,18 @@ def io_iterator_(frame, fnc, output_strategy="absolute", mix_names=False): Properly instantiated IOIterator object. """ + + # Create a new object that does not contain the ``self`` dict item + def _selfless_dict(_values): + return {key: val for key, val in _values.items() if key != "self"} + args, _, _, values = inspect.getargvalues(frame) args.remove("self") - del values["self"] + # Create a new object that does not contain the ``self`` dict item from the + # provided copy of the local symbol table returned by ``getargvalues``. + # Avoids attempting to remove it from the object returned by + # ``getargvalues``. + values = _selfless_dict(values) spargs, defaults = get_args_default(fnc)