dict_merge should not hiccup on None values
This commit is contained in:
parent
6963e5e495
commit
189c842881
1 changed files with 11 additions and 0 deletions
|
|
@ -470,6 +470,12 @@ def dict_merge(a, b):
|
|||
>>> expected = dict(foo="other foo", bar="bar", fnord=dict(a=1, b=2, l=["some", "list"]))
|
||||
>>> dict_merge(a, b) == expected
|
||||
True
|
||||
>>> dict_merge(a, None) == a
|
||||
True
|
||||
>>> dict_merge(None, b) == b
|
||||
True
|
||||
>>> dict_merge(None, None) == dict()
|
||||
True
|
||||
|
||||
Arguments:
|
||||
a (dict): The dictionary to merge ``b`` into
|
||||
|
|
@ -481,6 +487,11 @@ def dict_merge(a, b):
|
|||
|
||||
from copy import deepcopy
|
||||
|
||||
if a is None:
|
||||
a = dict()
|
||||
if b is None:
|
||||
b = dict()
|
||||
|
||||
if not isinstance(b, dict):
|
||||
return b
|
||||
result = deepcopy(a)
|
||||
|
|
|
|||
Loading…
Reference in a new issue