ERepublik: Fix huge memory exhaustion issue.

master
Valentin Lorentz 2013-05-23 19:06:52 +02:00
parent e82f9787b5
commit 4adf23e96f
1 changed files with 6 additions and 1 deletions

View File

@ -49,9 +49,14 @@ except:
_ = lambda x:x
internationalizeDocstring = lambda x:x
def flatten_subdicts(dicts, flat={}):
def flatten_subdicts(dicts, flat=None):
"""Change dict of dicts into a dict of strings/integers. Useful for
using in string formatting."""
if flat is None:
# Instanciate the dictionnary when the function is run and now when it
# is declared; otherwise the same dictionnary instance will be kept and
# it will have side effects (memory exhaustion, ...)
flat = {}
if isinstance(dicts, list):
return flatten_subdicts(dict(enumerate(dicts)))
elif isinstance(dicts, dict):