Issue #7084: Fix a (very unlikely) crash when printing a list from one

thread, and mutating it from another one.  Patch by Scott Dial.
This commit is contained in:
Antoine Pitrou 2009-10-11 21:03:26 +00:00
parent a4314c2b21
commit beaf6a02f4
3 changed files with 10 additions and 1 deletions

View File

@ -175,6 +175,7 @@ Arnaud Delobelle
Erik Demaine Erik Demaine
Roger Dev Roger Dev
Raghuram Devarakonda Raghuram Devarakonda
Scott Dial
Toby Dickenson Toby Dickenson
Mark Dickinson Mark Dickinson
Jack Diederich Jack Diederich

View File

@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #7084: Fix a (very unlikely) crash when printing a list from one
thread, and mutating it from another one. Patch by Scott Dial.
- Issue #1571184: The Unicode database contains properties for more characters. - Issue #1571184: The Unicode database contains properties for more characters.
The tables for code points representing numeric values, white spaces or line The tables for code points representing numeric values, white spaces or line
breaks are now generated from the official Unicode Character Database files, breaks are now generated from the official Unicode Character Database files,

View File

@ -319,6 +319,7 @@ list_print(PyListObject *op, FILE *fp, int flags)
{ {
int rc; int rc;
Py_ssize_t i; Py_ssize_t i;
PyObject *item;
rc = Py_ReprEnter((PyObject*)op); rc = Py_ReprEnter((PyObject*)op);
if (rc != 0) { if (rc != 0) {
@ -333,15 +334,19 @@ list_print(PyListObject *op, FILE *fp, int flags)
fprintf(fp, "["); fprintf(fp, "[");
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
for (i = 0; i < Py_SIZE(op); i++) { for (i = 0; i < Py_SIZE(op); i++) {
item = op->ob_item[i];
Py_INCREF(item);
if (i > 0) { if (i > 0) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
fprintf(fp, ", "); fprintf(fp, ", ");
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
} }
if (PyObject_Print(op->ob_item[i], fp, 0) != 0) { if (PyObject_Print(item, fp, 0) != 0) {
Py_DECREF(item);
Py_ReprLeave((PyObject *)op); Py_ReprLeave((PyObject *)op);
return -1; return -1;
} }
Py_DECREF(item);
} }
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
fprintf(fp, "]"); fprintf(fp, "]");