Skip to content

Commit

Permalink
BF: Fix attempting to delete frame local symbol table variable
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
jhlegarreta committed Jul 18, 2024
1 parent fa36fdb commit f808ccc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dipy/workflows/multi_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit f808ccc

Please sign in to comment.