This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: 'value' attribute for ValueError
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.5
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, barry, blackfawn, brett.cannon, cvrebert, ezio.melotti, pitrou
Priority: normal Keywords:

Created on 2013-06-07 20:56 by brett.cannon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg190781 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-06-07 20:56
A 'value attribute for ValueError could store a weakref to the value which triggered the exception. It should be a weakref so at to prevent accidental prevention of GC of the value.
msg228594 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-10-05 17:32
Just a gentle reminder guys.
msg240945 - (view) Author: Ofer Schwarz (blackfawn) * Date: 2015-04-14 16:53
There's actually no advantage for a weakref here, since the exception object already holds an indirect reference to all the raising frame's locals through __traceback__.
msg241033 - (view) Author: Ofer Schwarz (blackfawn) * Date: 2015-04-14 21:29
So, this is actually impossible to do.
Since exceptions are c-level classes, adding members to ValueError means anything that multiple-inherits from ValueError and any other complex exception gets a multiple bases layout conflict. There's already one such class - _pyio.UnsupportedOperation inherits both ValueError and OSError - but the bigger issue is that this would break compatibility.

After discussing it (face-to-face) with a bunch of core devs, I think the only reasonable course of action is to close the issue and never speak of this again.
msg241042 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-04-14 22:09
Thanks for the analysis. Closing then!
Date User Action Args
2022-04-11 14:57:46adminsetgithub: 62366
2015-04-14 22:09:41pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg241042

resolution: rejected
stage: test needed -> resolved
2015-04-14 21:29:19blackfawnsetmessages: + msg241033
2015-04-14 16:53:00blackfawnsetnosy: + blackfawn
messages: + msg240945
2014-10-05 17:32:34BreamoreBoysetnosy: + BreamoreBoy

messages: + msg228594
versions: + Python 3.5, - Python 3.4
2013-06-15 21:06:15ezio.melottisetnosy: + ezio.melotti
2013-06-14 16:26:05cvrebertsetnosy: + cvrebert
2013-06-07 21:23:57barrysetnosy: + barry
2013-06-07 20:56:56brett.cannoncreate