mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Really copy dict, not only the ref to the dict.
Code comment says dict is copied, but only ref to dict is copied: # Create a copy of the object that we will return. r = ret Here, the local var 'r' is pointing to the exact same dict as the 'ret' argument. I use <object>.copy() because 'ret' is expected to be a dict-like object, and dict have a (shallow) copy method. Shallow copy seems sufficient here because the '_generate_doc' method and subsequent users of its return only modify 1st level keys.
This commit is contained in:
parent
3e204c16f3
commit
8a38c2dbe2
@ -79,7 +79,7 @@ def _generate_doc(ret, options):
|
||||
'''
|
||||
|
||||
# Create a copy of the object that we will return.
|
||||
r = ret
|
||||
r = ret.copy()
|
||||
|
||||
# Set the ID of the document to be the JID.
|
||||
r["_id"] = ret["jid"]
|
||||
|
Loading…
Reference in New Issue
Block a user