Both gradient RPCs rebind the loop variable over the dict they are iterating:
philote_mdo/general/explicit_server.py:129
philote_mdo/general/implicit_server.py:325
for jac, value in jac.items():
On the first iteration jac stops being the PairDict of Jacobian blocks and becomes the (name, subname) key tuple.
Why it works today
dict.items() returns a view, and the for statement converts it to an iterator holding its own reference to the underlying dict before the first rebind happens. So the loop completes correctly and the tests pass.
Why it should be fixed
It is a trap for the next reader, and it breaks immediately under any refactor that needs to touch jac again inside or after the loop body — e.g. adding a second pass over the blocks, or referencing jac in an error message.
Fix
Rename the loop variable:
for key, value in jac.items():
...
name=key[0],
subname=key[1],
Same change in both files.
Both gradient RPCs rebind the loop variable over the dict they are iterating:
philote_mdo/general/explicit_server.py:129philote_mdo/general/implicit_server.py:325On the first iteration
jacstops being thePairDictof Jacobian blocks and becomes the(name, subname)key tuple.Why it works today
dict.items()returns a view, and theforstatement converts it to an iterator holding its own reference to the underlying dict before the first rebind happens. So the loop completes correctly and the tests pass.Why it should be fixed
It is a trap for the next reader, and it breaks immediately under any refactor that needs to touch
jacagain inside or after the loop body — e.g. adding a second pass over the blocks, or referencingjacin an error message.Fix
Rename the loop variable:
Same change in both files.