Skip to content

Commit

Permalink
py3: don't modify dict while iterating over it
Browse files Browse the repository at this point in the history
  • Loading branch information
nphilipp committed Nov 5, 2015
1 parent d6fa920 commit 66c7e3d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tw2/core/validation.py
Expand Up @@ -170,11 +170,16 @@ def __new__(meta, name, bases, dct):
except AttributeError: except AttributeError:
pass pass
msgs.update(dct['msgs']) msgs.update(dct['msgs'])
add_to_msgs = {}
del_from_msgs = []
for m, d in msgs.items(): for m, d in msgs.items():
if isinstance(d, tuple): if isinstance(d, tuple):
msgs[d[0]] = d[1] add_to_msgs[d[0]] = d[1]
rewrites[m] = d[0] rewrites[m] = d[0]
del msgs[m] del_from_msgs.append(m)
msgs.update(add_to_msgs)
for m in del_from_msgs:
del msgs[m]
dct['msgs'] = msgs dct['msgs'] = msgs
dct['msg_rewrites'] = rewrites dct['msg_rewrites'] = rewrites
if 'validate_python' in dct and '_validate_python' not in dct: if 'validate_python' in dct and '_validate_python' not in dct:
Expand Down

0 comments on commit 66c7e3d

Please sign in to comment.