Skip to content

Commit e81058c

Browse files
committed
Properly handle mapping of KeyError to AttributeError in __getattr__
Update doc indicating same mapping in __setattr__.
1 parent c095571 commit e81058c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

roundup/hyperdb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,15 +1724,15 @@ def __getattr__(self, name):
17241724
except KeyError as value:
17251725
# we trap this but re-raise it as AttributeError - all other
17261726
# exceptions should pass through untrapped
1727-
pass
1728-
# nope, no such attribute
1729-
raise AttributeError(str(value))
1727+
raise AttributeError(str(value))
17301728
def __getitem__(self, name):
17311729
return self.cl.get(self.nodeid, name)
17321730
def __setattr__(self, name, value):
17331731
try:
17341732
return self.cl.set(self.nodeid, **{name: value})
17351733
except KeyError as value:
1734+
# we trap this but re-raise it as AttributeError - all other
1735+
# exceptions should pass through untrapped
17361736
raise AttributeError(str(value))
17371737
def __setitem__(self, name, value):
17381738
self.cl.set(self.nodeid, **{name: value})

0 commit comments

Comments
 (0)