# HG changeset patch # User Simon Cross # Date 1283120174 -7200 # Node ID 168e9424fe91ca8a07317beb43ec693146d59c93 # Parent 0b33a502660cb7c786dc02194f57c4924f42d3dc Perform a deepcopy of INITIAL_DATA to allow mutable initial data to be used safely. diff -r 0b33a502660c -r 168e9424fe91 gamelib/state.py --- 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