Bugfix/unmunge (#1688)
* Fix cases where the unmunge misses keywords The unmunge would invariably miss keys due to the fact that the dict is modified while being iterated. This breaks out the keys into a list before iterating through them to ensure that all original keys are checked. * Clean up the unmunge function slightlypull/1696/head
parent
031daac17b
commit
ad5ebcf63d
|
@ -70,8 +70,9 @@ def unmunge_message(message, skill_id):
|
|||
"""
|
||||
if isinstance(message, Message) and isinstance(message.data, dict):
|
||||
skill_id = to_alnum(skill_id)
|
||||
for key in message.data:
|
||||
if key[:len(skill_id)] == skill_id:
|
||||
for key in list(message.data.keys()):
|
||||
if key.startswith(skill_id):
|
||||
# replace the munged key with the real one
|
||||
new_key = key[len(skill_id):]
|
||||
message.data[new_key] = message.data.pop(key)
|
||||
|
||||
|
|
Loading…
Reference in New Issue