[issue28214] Improve exception reporting for problematic __set_name__ attributes
Nick Coghlan
report at bugs.python.org
Wed Sep 21 11:22:05 EDT 2016
Nick Coghlan added the comment:
@property can be used to define a broken __set_name__ attribute:
>>> class BadIdea:
... @property
... def __set_name__(self):
... pass
...
>>> class NotGoingToWork:
... attr = BadIdea()
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
And there's also a failing __set_name__ call:
>>> class FaultyImplementation:
... def __set_name__(self, *args):
... 1/0
...
>>> class TheoreticallyCouldWork:
... attr = FaultyImplementation()
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __set_name__
ZeroDivisionError: division by zero
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28214>
_______________________________________
More information about the Python-bugs-list
mailing list