-
Notifications
You must be signed in to change notification settings - Fork 91
Closed
Description
It turns out that something that's OK on Python 3.4 may no longer be so in Python 3.5. The following code that modifies the OrderedDict content during the iteration fails on Python 3.5 but works fine on Python 3.4.
from collections import OrderedDict
d = OrderedDict([('a', 'a'), ('b', 'b'), ('c', 'c')])
for v in d.values():
if v == 'b':
d.pop(v)Mechanism similar to the above manipulation is actually used within our DataJoint code, and as a result the code works on Python 3.4, but fails on Python 3.5. This can be verified by the fact that our project code passing on TravisCI Python 3.4 platform fails on Python 3.5.
Given this, I propose that we include Python 3.5 as a target platform to test in addition to Python 3.4 and correct usage like above. Either way, modification of the iterator during the iteration is considered a bad practice with non-obvious consequences!
Metadata
Metadata
Assignees
Labels
No labels