[issue1517] lookdict should INCREF/DECREF startkey around PyObject_RichCompareBool

Guido van Rossum report at bugs.python.org
Thu Nov 29 19:19:33 CET 2007


Guido van Rossum added the comment:

I can reproduce the segfault in 2.2 through 2.4; in 2.5 and 2.6 the
output is this instead:

Test 1, using __eq__(a, b).__nonzero__()
this is never the right answer
*****
Test 2, using tuple's tp_richcompare
New Watch 0xf7f8cbac
New Watch 0xf7f8cc0c
Deleting Watch 0xf7f8cbac
Deleting Watch 0xf7f8cbac
Deleting Watch 0xf7f8cc0c
Traceback (most recent call last):
  File "/tmp/db3.py", line 72, in <module>
    print(d[(Bar(), Watch())])
TypeError: __eq__() takes exactly 1 argument (2 given)

which suggests it's still there ("this is never the right answer").

In 3.0 the output from the 1st test is "this is an acceptable answer"
suggesting it's no longer there; but I suspect it's there in 3.0 as well
but due to the unicode transition the dict code there is different
enough that the example doesn't trigger it.

The key that needs to be INCREF'ed is actually startkey.  Patch attached.

----------
nosy: +gvanrossum
versions: +Python 2.2, Python 2.2.1, Python 2.2.2, Python 2.2.3, Python 2.3, Python 2.4, Python 2.5, Python 2.6
Added file: http://bugs.python.org/file8826/fix1517.diff

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1517>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix1517.diff
Type: text/x-patch
Size: 506 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-bugs-list/attachments/20071129/dcc96195/attachment-0001.bin 


More information about the Python-bugs-list mailing list