summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-09-17 03:28:34 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-09-17 03:28:34 (GMT)
commit0153159e67bf4247c4402a1a6e717819372c9337 (patch)
treeef58a6813bfb4011b0cd542f250f292f8cba8076 /Objects/dictobject.c
parentd36a60e1e3410450d337d4de732e127e48a6a042 (diff)
downloadcpython-0153159e67bf4247c4402a1a6e717819372c9337.zip
cpython-0153159e67bf4247c4402a1a6e717819372c9337.tar.gz
cpython-0153159e67bf4247c4402a1a6e717819372c9337.tar.bz2
Add a bunch of GIL release/acquire points in tp_print implementations and for
PyObject_Print(). Closes issue #1164.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 30b3598..aa61e8c 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -867,11 +867,15 @@ dict_print(register dictobject *mp, register FILE *fp, register int flags)
if (status != 0) {
if (status < 0)
return status;
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, "{...}");
+ Py_END_ALLOW_THREADS
return 0;
}
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, "{");
+ Py_END_ALLOW_THREADS
any = 0;
for (i = 0; i <= mp->ma_mask; i++) {
dictentry *ep = mp->ma_table + i;
@@ -880,14 +884,19 @@ dict_print(register dictobject *mp, register FILE *fp, register int flags)
/* Prevent PyObject_Repr from deleting value during
key format */
Py_INCREF(pvalue);
- if (any++ > 0)
+ if (any++ > 0) {
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, ", ");
+ Py_END_ALLOW_THREADS
+ }
if (PyObject_Print((PyObject *)ep->me_key, fp, 0)!=0) {
Py_DECREF(pvalue);
Py_ReprLeave((PyObject*)mp);
return -1;
}
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, ": ");
+ Py_END_ALLOW_THREADS
if (PyObject_Print(pvalue, fp, 0) != 0) {
Py_DECREF(pvalue);
Py_ReprLeave((PyObject*)mp);
@@ -896,7 +905,9 @@ dict_print(register dictobject *mp, register FILE *fp, register int flags)
Py_DECREF(pvalue);
}
}
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, "}");
+ Py_END_ALLOW_THREADS
Py_ReprLeave((PyObject*)mp);
return 0;
}