[issue28214] Improve exception reporting for problematic __set_name__ attributes

Serhiy Storchaka report at bugs.python.org
Sun Oct 9 02:41:32 EDT 2016


Serhiy Storchaka added the comment:

Alternative patch chain original exception as __cause__ instead of __context__. What is better?

>>> class FaultyImplementation:
...     def __set_name__(self, *args):
...         1/0
... 
>>> class TheoreticallyCouldWork:
...     attr = FaultyImplementation()
... 
ZeroDivisionError: division by zero

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Error calling __set_name__ on 'FaultyImplementation' instance 'attr' in 'TheoreticallyCouldWork'

----------
Added file: http://bugs.python.org/file45029/set_name_chain_error_cause.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28214>
_______________________________________


More information about the Python-bugs-list mailing list