]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fixing #233200 - cPickle did not use Py_BEGIN_ALLOW_THREADS.
authorMoshe Zadka <moshez@math.huji.ac.il>
Sat, 31 Mar 2001 08:31:13 +0000 (08:31 +0000)
committerMoshe Zadka <moshez@math.huji.ac.il>
Sat, 31 Mar 2001 08:31:13 +0000 (08:31 +0000)
Misc/NEWS
Modules/cPickle.c

index 575bee5578594121ac72551bbf011e79bb5f2c27..7bc5b56b17eeb51d42b3816a059f2990052cf406 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -83,6 +83,8 @@ http://sourceforge.net/tracker/index.php?func=detail&aid=<id>&group_id=5470&atid
 - #128053 - posixmodule.c - #ifdef for including "tmpfile" in the 
             posix_methods[] array was wrong -- should be HAVE_TMPFILE
 
+- #233200 - cPickle did not use Py_BEGIN_ALLOW_THREADS.
+
 What's New in Python 2.0?
 =========================
 
index aac2e61ecb87570691e3a13aada0dc1481628627..ec36a8f39c068cca701fa36b3934deb8a188a8da 100644 (file)
@@ -401,13 +401,18 @@ cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...)
   return NULL;
 }
 
-static int 
+static int
 write_file(Picklerobject *self, char *s, int  n) {
+    size_t nbyteswritten;
+
     if (s == NULL) {
         return 0;
     }
 
-    if (fwrite(s, sizeof(char), n, self->fp) != (size_t)n) {
+    Py_BEGIN_ALLOW_THREADS
+    nbyteswritten = fwrite(s, sizeof(char), n, self->fp);
+    Py_END_ALLOW_THREADS
+    if (nbyteswritten != (size_t)n) {
         PyErr_SetFromErrno(PyExc_IOError);
         return -1;
     }
@@ -472,21 +477,22 @@ write_other(Picklerobject *self, char *s, int  n) {
         if (junk) Py_DECREF(junk);
         else return -1;
       }
-    else 
+    else
       PDATA_PUSH(self->file, py_str, -1);
-    
-    self->buf_size = 0; 
+
+    self->buf_size = 0;
     return n;
 }
 
 
-static int 
+static int
 read_file(Unpicklerobject *self, char **s, int  n) {
+    size_t nbytesread;
 
     if (self->buf_size == 0) {
         int size;
 
-        size = ((n < 32) ? 32 : n); 
+        size = ((n < 32) ? 32 : n);
         UNLESS (self->buf = (char *)malloc(size * sizeof(char))) {
             PyErr_NoMemory();
             return -1;
@@ -499,11 +505,14 @@ read_file(Unpicklerobject *self, char **s, int  n) {
             PyErr_NoMemory();
             return -1;
         }
+
         self->buf_size = n;
     }
-            
-    if (fread(self->buf, sizeof(char), n, self->fp) != (size_t)n) {
+
+    Py_BEGIN_ALLOW_THREADS
+    nbytesread = fread(self->buf, sizeof(char), n, self->fp);
+    Py_END_ALLOW_THREADS
+    if (nbytesread != (size_t)n) {
         if (feof(self->fp)) {
             PyErr_SetNone(PyExc_EOFError);
             return -1;