Mercurial > pyntnclick
diff gamelib/state.py @ 498:168e9424fe91
Perform a deepcopy of INITIAL_DATA to allow mutable initial data to be used safely.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 00:16:14 +0200 |
parents | a7ed199f69d5 |
children | 93ddcac0b772 |
line wrap: on
line diff
--- a/gamelib/state.py Sun Aug 29 21:35:05 2010 +0200 +++ b/gamelib/state.py Mon Aug 30 00:16:14 2010 +0200 @@ -1,5 +1,7 @@ """Utilities and base classes for dealing with scenes.""" +import copy + from albow.resource import get_image, get_font from albow.utils import frame_rect from widgets import BoomLabel @@ -236,7 +238,9 @@ def __init__(self): self.data = {} if self.INITIAL_DATA: - self.data.update(self.INITIAL_DATA) + # deep copy of INITIAL_DATA allows lists, sets and + # other mutable types to safely be used in INITIAL_DATA + self.data.update(copy.deepcopy(self.INITIAL_DATA)) def set_data(self, key, value): self.data[key] = value