Add "raise from" on keyerror.
This commit is contained in:
parent
e24e89a04b
commit
24f74e9ee4
1 changed files with 2 additions and 2 deletions
|
@ -20,10 +20,10 @@ class DotDict:
|
||||||
def __getattr__(self, key):
|
def __getattr__(self, key):
|
||||||
try:
|
try:
|
||||||
return self.__dict__[key]
|
return self.__dict__[key]
|
||||||
except KeyError:
|
except KeyError as exc:
|
||||||
if self.__default is not NO_DEFAULT:
|
if self.__default is not NO_DEFAULT:
|
||||||
return self.__default
|
return self.__default
|
||||||
raise
|
raise AttributeError from exc
|
||||||
|
|
||||||
def __setattr__(self, key, value):
|
def __setattr__(self, key, value):
|
||||||
self.__dict__[key] = value
|
self.__dict__[key] = value
|
||||||
|
|
Loading…
Reference in a new issue