diff roundup/hyperdb.py @ 5697:5a9159ad773f

Properly handle mapping of KeyError to AttributeError in __getattr__ Update doc indicating same mapping in __setattr__.
author John Rouillard <rouilj@ieee.org>
date Mon, 08 Apr 2019 19:38:06 -0400
parents a4514df51ded
children 0467d80eaeec
line wrap: on
line diff
--- a/roundup/hyperdb.py	Sun Apr 07 20:27:25 2019 -0400
+++ b/roundup/hyperdb.py	Mon Apr 08 19:38:06 2019 -0400
@@ -1724,15 +1724,15 @@
         except KeyError as value:
             # we trap this but re-raise it as AttributeError - all other
             # exceptions should pass through untrapped
-            pass
-        # nope, no such attribute
-        raise AttributeError(str(value))
+            raise AttributeError(str(value))
     def __getitem__(self, name):
         return self.cl.get(self.nodeid, name)
     def __setattr__(self, name, value):
         try:
             return self.cl.set(self.nodeid, **{name: value})
         except KeyError as value:
+            # we trap this but re-raise it as AttributeError - all other
+            # exceptions should pass through untrapped
             raise AttributeError(str(value))
     def __setitem__(self, name, value):
         self.cl.set(self.nodeid, **{name: value})

Roundup Issue Tracker: http://roundup-tracker.org/