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 abacabadabacaba
Recipients abacabadabacaba, rhettinger
Date 2010-04-18.19:11:00
SpamBayes Score 4.3485215e-12
Marked as misclassified No
Message-id <1271617862.83.0.606876629857.issue8420@psf.upfronthosting.co.za>
In-reply-to
Content
> > One solution is to check that so->mask didn't 
> > change as well. 
> 
> I saw that and agree it would make a tighter check, but haven't convinced myself that it is necessary.

Without this check, it is possible that the comparison shrinks the table, so entry becomes out of bounds. However, if both so->table and so->mask didn't change then entry is still a pointer to one of table elements so it can be used safely.

> > Also, checking that refcnt > 1 is redundant 
> > because if entry->key == startkey then there 
> > are at least two references: one from entry->key 
> > and another from startkey.
> 
> It is a meaningful check.  We have our own INCREF
> and one for the key being in the table.  If the
> count is 1, then it means that the comparison
> check deleted the key from the table or replaced
> its value (see issue 1517).

If the comparison deleted or changed the key then the check entry->key == startkey would fail so refcnt check won't be reached. Checking refcounts is also bad because someone else may have references to the key.

> I don't follow why you think keys is already deallocated.
> When assigned by PySequence_List() without a NULL return, the refcnt is one. The call to PyObject_Repr(keys) does not change the refcnt of keys,
> so the Py_DECREF(keys) is correct.
Look at the code again. If listrepr happens to be NULL, you do Py_DECREF(keys) twice (this bug is only present in py3k branch).
History
Date User Action Args
2010-04-18 19:11:03abacabadabacabasetrecipients: + abacabadabacaba, rhettinger
2010-04-18 19:11:02abacabadabacabasetmessageid: <1271617862.83.0.606876629857.issue8420@psf.upfronthosting.co.za>
2010-04-18 19:11:01abacabadabacabalinkissue8420 messages
2010-04-18 19:11:00abacabadabacabacreate