-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Description
What was wrong?
There is a dict_copy decorator used in the ens module. It is intended to allow us to write methods like this:
@dict_copy
def my_method(self, some_params={}):
...
Normally using a mutable value like a dictionary as a default argument is problematic because the same mutable object is used across each call. This decorator institutes a copy of this, but only if it is passed as a keyword argument.
There are at least some places where dict_copy is used but where the parameter that needs to be copied is not enforced to be a keyword argument, meaning that any calls that use it positionally will not benefit from the protection.
How can it be fixed?
I'm inclined to suggest removing the decorator entirely and changing all places it was used to follow the standard pattern of:
def my_method(self, some_params=None):
if some_params is None:
some_params = {}
...