Permalink
Browse files

py3: don't modify dict while iterating over it

  • Loading branch information...
nphilipp committed Nov 5, 2015
1 parent d6fa920 commit 66c7e3d8d0bcae6fe6d55bd5144c7991e02fe654
Showing with 7 additions and 2 deletions.
  1. +7 −2 tw2/core/validation.py
@@ -170,11 +170,16 @@ def __new__(meta, name, bases, dct):
except AttributeError:
pass
msgs.update(dct['msgs'])
add_to_msgs = {}
del_from_msgs = []
for m, d in msgs.items():
if isinstance(d, tuple):
msgs[d[0]] = d[1]
add_to_msgs[d[0]] = d[1]
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['msg_rewrites'] = rewrites
if 'validate_python' in dct and '_validate_python' not in dct:

0 comments on commit 66c7e3d

Please sign in to comment.