Status: Accepted
Owner: [email protected]
Labels: Type-Defect Priority-Medium
New issue 2333 by [email protected]: powsimp is iterating over a dictionary
that is deleted during iteration
http://code.google.com/p/sympy/issues/detail?id=2333
There is a strange piece of code in powsimp that, while traversing c_exp
deletes c_exp and rebuilds it with the same number of arguments. This
apparently hasn't caused any problems but I'm not sure that there is a
guarantee that after, rebuilding, all the arguments not yet traversed will
be traversed. And at least, it might mean that the new argument gets
traversed again. Here is a sample session showing two different iterations
over a dictionary doing this sort of thing:
>>> d={1:2,3:4}
>>> for e in d:
... del d[e]
... d[e+10]=5
... print e, d
...
1 {11: 5, 3: 4}
3 {11: 5, 13: 5}
13 {11: 5, 23: 5}
23 {11: 5, 33: 5}
>>> d={1:2,3:4}
>>> for e in d:
... del d[e]
... d[e-10]=5
... print e, d
...
1 {3: 4, -9: 5}
3 {-7: 5, -9: 5}
-9 {-7: 5, -19: 5}
The correction to this is in pull request 267.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.