[issue28214] Improve exception reporting for problematic __set_name__ attributes

Serhiy Storchaka report at bugs.python.org
Sun Oct 9 02:31:21 EDT 2016


Serhiy Storchaka added the comment:

Shouldn't it be RuntimeError?

Proposed patch makes RuntimeError be raised with chained original exception. This preserves more information.

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

During handling of the above exception, another exception occurred:

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/file45028/set_name_error.patch

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


More information about the Python-bugs-list mailing list