Skip to content
This repository was archived by the owner on May 8, 2018. It is now read-only.

Commit 4c111d3

Browse files
committed
Fixed RuntimeError: dictionary changed size during iteration #PAYAB-2371
1 parent aea79b3 commit 4c111d3

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

mws/mws.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import base64
1212
import utils
1313
import re
14+
import six
15+
1416
try:
1517
from xml.etree.ElementTree import ParseError as XMLError
1618
except ImportError:
@@ -73,10 +75,7 @@ def remove_empty(d):
7375
Helper function that removes all keys from a dictionary (d),
7476
that have an empty value.
7577
"""
76-
for key in d.keys():
77-
if not d[key]:
78-
del d[key]
79-
return d
78+
return dict((key, value) for key, value in six.iteritems(d) if value)
8079

8180

8281
def remove_namespace(xml):

0 commit comments

Comments
 (0)