summaryrefslogtreecommitdiffstats
path: root/Modules
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 /Modules
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 'Modules')
-rw-r--r--Modules/_collectionsmodule.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 7f5e2ae..ea68f80 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -652,7 +652,9 @@ deque_tp_print(PyObject *deque, FILE *fp, int flags)
if (i != 0) {
if (i < 0)
return i;
+ Py_BEGIN_ALLOW_THREADS
fputs("[...]", fp);
+ Py_END_ALLOW_THREADS
return 0;
}
@@ -660,9 +662,13 @@ deque_tp_print(PyObject *deque, FILE *fp, int flags)
if (it == NULL)
return -1;
+ Py_BEGIN_ALLOW_THREADS
fputs("deque([", fp);
+ Py_END_ALLOW_THREADS
while ((item = PyIter_Next(it)) != NULL) {
+ Py_BEGIN_ALLOW_THREADS
fputs(emit, fp);
+ Py_END_ALLOW_THREADS
emit = separator;
if (PyObject_Print(item, fp, 0) != 0) {
Py_DECREF(item);
@@ -676,7 +682,9 @@ deque_tp_print(PyObject *deque, FILE *fp, int flags)
Py_DECREF(it);
if (PyErr_Occurred())
return -1;
+ Py_BEGIN_ALLOW_THREADS
fputs("])", fp);
+ Py_END_ALLOW_THREADS
return 0;
}
@@ -1190,15 +1198,24 @@ static int
defdict_print(defdictobject *dd, FILE *fp, int flags)
{
int sts;
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, "defaultdict(");
- if (dd->default_factory == NULL)
+ Py_END_ALLOW_THREADS
+ if (dd->default_factory == NULL) {
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, "None");
+ Py_END_ALLOW_THREADS
+ }
else {
PyObject_Print(dd->default_factory, fp, 0);
}
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, ", ");
+ Py_END_ALLOW_THREADS
sts = PyDict_Type.tp_print((PyObject *)dd, fp, 0);
+ Py_BEGIN_ALLOW_THREADS
fprintf(fp, ")");
+ Py_END_ALLOW_THREADS
return sts;
}