mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-14 16:11:43 +00:00
Merge pull request #5496 from ThomasWaldmann/item-assert-dict
PropDict: fail early if internal_dict is not a dict
This commit is contained in:
commit
1f3a91f72f
1 changed files with 12 additions and 6 deletions
|
@ -40,15 +40,21 @@ class PropDict:
|
|||
__slots__ = ("_dict", ) # avoid setting attributes not supported by properties
|
||||
|
||||
def __init__(self, data_dict=None, internal_dict=None, **kw):
|
||||
self._dict = {}
|
||||
if internal_dict is None:
|
||||
pass # nothing to do
|
||||
elif isinstance(internal_dict, dict):
|
||||
self.update_internal(internal_dict)
|
||||
else:
|
||||
raise TypeError("internal_dict must be a dict")
|
||||
if data_dict is None:
|
||||
data = kw
|
||||
elif not isinstance(data_dict, dict):
|
||||
raise TypeError("data_dict must be dict")
|
||||
else:
|
||||
elif isinstance(data_dict, dict):
|
||||
data = data_dict
|
||||
self._dict = {}
|
||||
self.update_internal(internal_dict or {})
|
||||
self.update(data)
|
||||
else:
|
||||
raise TypeError("data_dict must be a dict")
|
||||
if data:
|
||||
self.update(data)
|
||||
|
||||
def update(self, d):
|
||||
for k, v in d.items():
|
||||
|
|
Loading…
Add table
Reference in a new issue