[Python-checkins] CVS: python/dist/src/Modules cPickle.c,2.53.2.1,2.53.2.2

Moshe Zadka moshez@users.sourceforge.net
Sat, 31 Mar 2001 00:31:15 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv4531/Modules

Modified Files:
      Tag: release20-maint
	cPickle.c 
Log Message:
Fixing #233200 - cPickle did not use Py_BEGIN_ALLOW_THREADS.


Index: cPickle.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v
retrieving revision 2.53.2.1
retrieving revision 2.53.2.2
diff -C2 -r2.53.2.1 -r2.53.2.2
*** cPickle.c	2001/03/30 17:20:58	2.53.2.1
--- cPickle.c	2001/03/31 08:31:13	2.53.2.2
***************
*** 402,412 ****
  }
  
! static int 
  write_file(Picklerobject *self, char *s, int  n) {
      if (s == NULL) {
          return 0;
      }
  
!     if (fwrite(s, sizeof(char), n, self->fp) != (size_t)n) {
          PyErr_SetFromErrno(PyExc_IOError);
          return -1;
--- 402,417 ----
  }
  
! static int
  write_file(Picklerobject *self, char *s, int  n) {
+     size_t nbyteswritten;
+ 
      if (s == NULL) {
          return 0;
      }
  
!     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;
***************
*** 473,491 ****
          else return -1;
        }
!     else 
        PDATA_PUSH(self->file, py_str, -1);
!     
!     self->buf_size = 0; 
      return n;
  }
  
  
! static int 
  read_file(Unpicklerobject *self, char **s, int  n) {
  
      if (self->buf_size == 0) {
          int size;
  
!         size = ((n < 32) ? 32 : n); 
          UNLESS (self->buf = (char *)malloc(size * sizeof(char))) {
              PyErr_NoMemory();
--- 478,497 ----
          else return -1;
        }
!     else
        PDATA_PUSH(self->file, py_str, -1);
! 
!     self->buf_size = 0;
      return n;
  }
  
  
! 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);
          UNLESS (self->buf = (char *)malloc(size * sizeof(char))) {
              PyErr_NoMemory();
***************
*** 500,508 ****
              return -1;
          }
!  
          self->buf_size = n;
      }
!             
!     if (fread(self->buf, sizeof(char), n, self->fp) != (size_t)n) {
          if (feof(self->fp)) {
              PyErr_SetNone(PyExc_EOFError);
--- 506,517 ----
              return -1;
          }
! 
          self->buf_size = 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);