__getattr__ in BillogramAPIError is surprising
pelme opened this issue · comments
In billogram_api.py, in BillogramAPIError:
def __getattr__(self, name):
# called just for non-existent keys, just pretend those are blank
# makes handling of keyword arguments to constructor easier
return None
Changing the way attributes works on exception objects like this is just not what you expect.
Also, "blank" for the most part does not mean "None". This leads to very surprising things when you do things hasattr(exception, 'someattr') always returns True, even if the attribute does not exist.
We set custom attributes on exceptions when they bubble up from context managers to annotate logging data.
Totally agree with you here, I'm not sure myself why it works in this specific way. We'll try to make it work better in a future update. Hopefully you can work around it until then.
Thank you for your feedback!
Thank you! I've added a special case that explicitly checks for our specific attribute being None and just replaces it then.