You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was reading the source code of fixer_util.py and I noticed that one item enumerate was not like the others in consuming_calls because it does not actually consume the iterable in python 2 or python 3.
For example, fissix leaves this unchanged (without wrapping in list()) because it thinks that enumerate will consume the python 3 iterable: enumerate(d.items()). But it should wrap it in list because you might mutate d inside a loop: for i, x in enumerate(d.items()): del d[x] which will raise “RuntimeError: dictionary changed size during iteration” in python 3.
Instead, enumerate should be handled the same as iter.
Details
OS: any
Python version: any
fissix version: 21.6.6
Can you repro on master? yes
Can you repro in a clean virtualenv? yes
The text was updated successfully, but these errors were encountered:
Description
I was reading the source code of fixer_util.py and I noticed that one item
enumerate
was not like the others inconsuming_calls
because it does not actually consume the iterable in python 2 or python 3.For example, fissix leaves this unchanged (without wrapping in
list()
) because it thinks thatenumerate
will consume the python 3 iterable:enumerate(d.items())
. But it should wrap it inlist
because you might mutated
inside a loop:for i, x in enumerate(d.items()): del d[x]
which will raise “RuntimeError: dictionary changed size during iteration” in python 3.Instead,
enumerate
should be handled the same asiter
.Details
The text was updated successfully, but these errors were encountered: