Skip to content

Commit 686c8fa

Browse files
committed
PYTHON-710, SON.to_dict shouldn't change original data.
1 parent 91a5670 commit 686c8fa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

bson/son.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ def to_dict(self):
226226
def transform_value(value):
227227
if isinstance(value, list):
228228
return [transform_value(v) for v in value]
229-
if isinstance(value, SON):
230-
value = dict(value)
231-
if isinstance(value, dict):
232-
for k, v in value.iteritems():
233-
value[k] = transform_value(v)
234-
return value
229+
elif isinstance(value, dict):
230+
return dict([
231+
(k, transform_value(v))
232+
for k, v in value.iteritems()])
233+
else:
234+
return value
235235

236236
return transform_value(dict(self))
237237

0 commit comments

Comments
 (0)