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.

Author Rhamphoryncus
Recipients Rhamphoryncus
Date 2007-11-29.01:41:09
SpamBayes Score 0.13318628
Marked as misclassified No
Message-id <1196300470.07.0.800454639703.issue1517@psf.upfronthosting.co.za>
In-reply-to
Content
(thanks go to my partner in crime, jorendorff, for helping flesh this out.)

lookdict calls PyObject_RichCompareBool without using INCREF/DECREF on
the key passed.  It's possible for the comparison to delete the key from
the dict, causing its own argument to be deallocated.  This can lead to
bogus results or a crash.

A custom type with its own __eq__ method will implicitly INCREF the key
when passing it as an argument, which prevents incorrect behaviour from
manifesting.  There are a couple ways around this though, as shown in my
attachment.
Files
File name Uploaded
dictbug.py Rhamphoryncus, 2007-11-29.01:41:09
History
Date User Action Args
2007-11-29 01:41:10Rhamphoryncussetspambayes_score: 0.133186 -> 0.13318628
recipients: + Rhamphoryncus
2007-11-29 01:41:10Rhamphoryncussetspambayes_score: 0.133186 -> 0.133186
messageid: <1196300470.07.0.800454639703.issue1517@psf.upfronthosting.co.za>
2007-11-29 01:41:09Rhamphoryncuslinkissue1517 messages
2007-11-29 01:41:09Rhamphoryncuscreate