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 rhettinger
Recipients rhettinger
Date 2011-12-03.00:30:27
SpamBayes Score 5.694156e-06
Marked as misclassified No
Message-id <>
A dialog on python-dev suggests that dict.setdefault() was intended to be atomic and that a number of experienced developers have deployed code relying on its atomicity:

The actual implementation shows a second call to PyDict_Setitem() which can call PyObject_Hash() which can call arbitrary Python code.

This fix is straight-forward, use the results of the initial lookup to insert the default object.  This will make the operation atomic and it will make it faster.
Date User Action Args
2011-12-03 00:30:29rhettingersetrecipients: + rhettinger
2011-12-03 00:30:28rhettingersetmessageid: <>
2011-12-03 00:30:28rhettingerlinkissue13521 messages
2011-12-03 00:30:27rhettingercreate