Skip to content

Commit 9036a2f

Browse files
committed
Use copy to prevent RuntimeErrors
1 parent 35214a6 commit 9036a2f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

shinobu/beacon/protocol/messages.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,23 @@ def save(self):
9393
# So if any errors arise, it may be acceptable to ignore them and lose the cached message
9494
# or message group causing the errors.
9595

96+
# Copy data
97+
data: dict = self._data.copy()
98+
data_groups: dict = self._data_groups.copy()
99+
96100
# Convert data to dictionary
97101
converted = {}
98-
for message in self._data:
102+
for message in data:
99103
try:
100-
converted.update({message: self._data[message].to_dict()})
104+
converted.update({message: data[message].to_dict()})
101105
except AttributeError:
102106
# Assume something is just set to None
103107
continue
104108

105109
converted_groups = {}
106-
for group in self._data_groups:
110+
for group in data_groups:
107111
try:
108-
converted_groups.update({group: self._data_groups[group].to_dict()})
112+
converted_groups.update({group: data_groups[group].to_dict()})
109113
except AttributeError:
110114
# Assume something is just set to None
111115
continue

0 commit comments

Comments
 (0)