[Python-ideas] the error that raises an AttributeError should be passed to __getattr__
jjmaldonis at gmail.com
Mon Jun 19 17:06:56 EDT 2017
A while back I had a conversation with some folks over on python-list. I
was having issues implementing error handling of `AttributeError`s using
My problem is that it is currently impossible for a `__getattr__` in Python
to know which method raised the `AttributeError` that was caught by
`__getattr__` if there are nested methods.
For example, we cannot tell the difference between `A.x` not existing
(which would raise an AttributeError) and some attribute inside `A.x` not
existing (which also raises an AttributeError). This is evident from the
stack trace that gets printed to screen, but `__getattr__` doesn't get that
I propose that the error that triggers an `AttributeError` should get
passed to `__getattr__` (if `__getattr__` exists of course). Then, when
handling errors, users could dig into the problematic error if they so
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas