diff options
author | Raymond Hettinger <python@rcn.com> | 2007-10-05 19:07:31 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-10-05 19:07:31 (GMT) |
commit | 556b43d936e83d15a062c668be19de739d587f90 (patch) | |
tree | 7dc438db32ab5e99bd0b69a941e96cf5a8b83a56 /Modules | |
parent | 44f326ef2ae0abdbac7ebeddf4b14664ed4a1367 (diff) | |
download | cpython-556b43d936e83d15a062c668be19de739d587f90.zip cpython-556b43d936e83d15a062c668be19de739d587f90.tar.gz cpython-556b43d936e83d15a062c668be19de739d587f90.tar.bz2 |
Restore BEGIN/END THREADS macros which were squashed in the previous checkin
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_collectionsmodule.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 78a71bf..cd8ddca 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -631,7 +631,7 @@ PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); static PyObject * deque_repr(PyObject *deque) { - PyObject *aslist, *result, *fmt; /*, *limit; */ + PyObject *aslist, *result, *fmt; int i; i = Py_ReprEnter(deque); @@ -656,7 +656,7 @@ deque_repr(PyObject *deque) Py_ReprLeave(deque); return NULL; } - result = PyString_Format(fmt, aslist); + result = PyString_Format(fmt, aslist); Py_DECREF(fmt); Py_DECREF(aslist); Py_ReprLeave(deque); @@ -675,7 +675,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; } @@ -683,9 +685,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); @@ -700,10 +706,12 @@ deque_tp_print(PyObject *deque, FILE *fp, int flags) if (PyErr_Occurred()) return -1; + Py_BEGIN_ALLOW_THREADS if (((dequeobject *)deque)->maxlen == -1) fputs("])", fp); else - fprintf(fp, "], maxlen=%d)", ((dequeobject *)deque)->maxlen); + fprintf(fp, "], maxlen=%d)", ((dequeobject *)deque)->maxlen); + Py_END_ALLOW_THREADS return 0; } @@ -1223,15 +1231,23 @@ 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"); - else { + 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; } |