Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions telegram/ext/dictpersistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the DictPersistence class."""
from copy import deepcopy

from telegram.utils.helpers import decode_user_chat_data_from_json,\
decode_conversations_from_json, enocde_conversations_to_json

Expand Down Expand Up @@ -129,7 +131,7 @@ def get_user_data(self):
pass
else:
self._user_data = defaultdict(dict)
return self.user_data.copy()
return deepcopy(self.user_data)

def get_chat_data(self):
"""Returns the chat_data created from the ``chat_data_json`` or an empty defaultdict.
Expand All @@ -141,7 +143,7 @@ def get_chat_data(self):
pass
else:
self._chat_data = defaultdict(dict)
return self.chat_data.copy()
return deepcopy(self.chat_data)

def get_conversations(self, name):
"""Returns the conversations created from the ``conversations_json`` or an empty
Expand Down
5 changes: 3 additions & 2 deletions telegram/ext/picklepersistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""This module contains the PicklePersistence class."""
import pickle
from collections import defaultdict
from copy import deepcopy

from telegram.ext import BasePersistence

Expand Down Expand Up @@ -122,7 +123,7 @@ def get_user_data(self):
self.user_data = data
else:
self.load_singlefile()
return self.user_data.copy()
return deepcopy(self.user_data)

def get_chat_data(self):
"""Returns the chat_data from the pickle file if it exsists or an empty defaultdict.
Expand All @@ -142,7 +143,7 @@ def get_chat_data(self):
self.chat_data = data
else:
self.load_singlefile()
return self.chat_data.copy()
return deepcopy(self.chat_data)

def get_conversations(self, name):
"""Returns the conversations from the pickle file if it exsists or an empty defaultdict.
Expand Down