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.

classification
Title: Let dicts propagate the exceptions in user __eq__
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: arigo, tim.peters
Priority: normal Keywords: patch

Created on 2006-05-29 16:54 by arigo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python24-dictobject.diff arigo, 2006-05-29 17:48 Python 2.4 patch (#2).
python25-dictobject.diff arigo, 2006-05-29 17:50 Python 2.5 patch (#3).
Messages (5)
msg50380 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-05-29 16:54
Patch for bug #1275608.

Exceptions occurring when the dict lookup code calls a
user-defined __eq__() are silently eaten.  This has
caused me several hours-long debugging session so far,
so I thought that it was time to fix that.

The proposed patch takes an easy route: it doesn't try
to change PyDict_GetItem(), which still has no way to
report exceptions and just eats them.  Instead, it moves
the exception-eating logic into PyDict_GetItem().  So 
all other ways in which dicts are accessed now correctly
report exceptions.  Most importantly, this includes all
operators and methods accessible from Python code,
including the 'x=d[key]' syntax.

The only incompatibility I could imagine from this would
be from code that relies on the fact that dicts were
previouly tolerant about exceptions: an __eq__ could
fail in any way, and the lookup would consider it as a
"not equal" signal and proceed.  I'd say "fix that". 
However it means that the 2.4 patch attached here should
probably not be applied, sadly.  I'd vote to check in
the 2.5 patch as soon as possible.

Note that these patches sneak in another bugfix patch
too (#1456209) because I couldn't be bothered to
maintain two mutually-conflicting patches.
msg50381 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-05-29 17:47
Logged In: YES 
user_id=4771

Updated the patches; added more tests for 2.5.
msg50382 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-06-01 13:19
Logged In: YES 
user_id=4771

Checked in as r46589.
msg50383 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-06-01 15:53
Logged In: YES 
user_id=31435

Thank you!  Marking as Closed.  I made a few minor changes
(you checked it in while I was reviewing the patch), but you
won't object to them ;-)
msg50384 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-06-01 19:14
Logged In: YES 
user_id=4771

Oups, I left an 'unsigned int' by mistake.  Thanks.

(Sidenotedly, you and me closed all three related SF trackers
at about the same time, so I guess it's why each of us
thinks he's the one that closed them :-)
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43432
2006-05-29 16:54:43arigocreate