[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.
Martin
report at bugs.python.org
Mon Oct 25 03:41:52 EDT 2021
Martin <martin.schroeder at nerdluecht.de> added the comment:
> Can we determine if they came from an initialized object or from object in the middle of initialization?
That would be very nice because inside __init__ is the only place where we have to deal with partly initialized objects. But I think Python does not provide a way to detect this state.
Although I would very much like having FrameSummary robust to any kind error, I acknowledge that this might not be possible.
It might be frustrating for beginners, but I think the only way to "fix" this, is by having people implement their `repr`s correctly.
The documentation currently says[1]:
> This is typically used for debugging, so it is important that the representation is information-rich and unambiguous.
It should be added that __repr__ might be used to display partly initialized objects during debugging and therefore should deal with these gracefully.
[1] https://docs.python.org/3/reference/datamodel.html#object.__repr__
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43656>
_______________________________________
More information about the Python-bugs-list
mailing list