From 549524410137e15cd2ffcb91937c04c18d996ef7 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sun, 28 Dec 2014 01:53:26 +0100 Subject: [PATCH 1/1] Task: Make a dict.copy() for _original_data --- tasklib/task.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tasklib/task.py b/tasklib/task.py index 3860f8e..44c6965 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -29,7 +29,9 @@ class TaskResource(object): def _load_data(self, data): self._data = data - self._original_data = data + # We need to use a copy for original data, so that changes + # are not propagated + self._original_data = data.copy() def __getitem__(self, key): hydrate_func = getattr(self, 'deserialize_{0}'.format(key), @@ -276,7 +278,10 @@ class Task(TaskResource): self._original_data.update(to_update) else: self._data = new_data - self._original_data = new_data + # We need to create a clone for original_data though + # Shallow copy is alright, since data dict uses only + # primitive data types + self._original_data = new_data.copy() class TaskFilter(object): -- 2.39.5