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 | <1322872228.97.0.525171057572.issue13521@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
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: http://mail.python.org/pipermail/python-3000/2007-July/008693.html The actual implementation shows a second call to PyDict_Setitem() which can call PyObject_Hash() which can call arbitrary Python code. http://hg.python.org/cpython/file/2.7/Objects/dictobject.c#l1937 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. |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2011年12月03日 00:30:29 | rhettinger | set | recipients: + rhettinger |
| 2011年12月03日 00:30:28 | rhettinger | set | messageid: <1322872228.97.0.525171057572.issue13521@psf.upfronthosting.co.za> |
| 2011年12月03日 00:30:28 | rhettinger | link | issue13521 messages |
| 2011年12月03日 00:30:27 | rhettinger | create | |