[Python-checkins] CVS: python/dist/src/Modules zlibmodule.c,2.45,2.46

Jeremy Hylton jhylton@users.sourceforge.net
Tue, 16 Oct 2001 14:24:00 -0700


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

Modified Files:
	zlibmodule.c 
Log Message:
Remove many calls to set MemoryError exceptions.

When PyString_FromStringAndSize() and _PyString_Resize() fail, they
set an exception.  There's no need to set a new exception.


Index: zlibmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/zlibmodule.c,v
retrieving revision 2.45
retrieving revision 2.46
diff -C2 -d -r2.45 -r2.46
*** zlibmodule.c	2001/10/16 21:19:45	2.45
--- zlibmodule.c	2001/10/16 21:23:58	2.46
***************
*** 146,151 ****
  	PyErr_SetString(PyExc_MemoryError,
  			"Can't allocate memory to compress data");
- 	free(output);
- 
  	return NULL;
      }
--- 146,149 ----
***************
*** 267,275 ****
      zst.avail_out = r_strlen;
  
!     if (!(result_str = PyString_FromStringAndSize(NULL, r_strlen))) {
! 	PyErr_SetString(PyExc_MemoryError,
! 			"Can't allocate memory to decompress data");
  	return NULL;
-     }
  
      /* Past the point of no return.  From here on out, we need to make sure
--- 265,270 ----
      zst.avail_out = r_strlen;
  
!     if (!(result_str = PyString_FromStringAndSize(NULL, r_strlen)))
  	return NULL;
  
      /* Past the point of no return.  From here on out, we need to make sure
***************
*** 335,340 ****
  	    /* need more memory */
  	    if (_PyString_Resize(&result_str, r_strlen << 1) == -1) {
- 		PyErr_SetString(PyExc_MemoryError,
- 				"Out of memory while decompressing data");
  		inflateEnd(&zst);
  		result_str = NULL;
--- 330,333 ----
***************
*** 529,537 ****
  	return NULL;
  
!     if (!(RetVal = PyString_FromStringAndSize(NULL, length))) {
! 	PyErr_SetString(PyExc_MemoryError,
! 			"Can't allocate memory to compress data");
  	return NULL;
-     }
  
      ENTER_ZLIB
--- 522,527 ----
  	return NULL;
  
!     if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
  	return NULL;
  
      ENTER_ZLIB
***************
*** 555,560 ****
      while (err == Z_OK && self->zst.avail_out == 0) {
  	if (_PyString_Resize(&RetVal, length << 1) == -1)  {
- 	    PyErr_SetString(PyExc_MemoryError,
- 			    "Can't allocate memory to compress data");
  	    return_error = 1;
  	    break;
--- 545,548 ----
***************
*** 636,644 ****
      if (max_length && length > max_length) 
  	length = max_length;
!     if (!(RetVal = PyString_FromStringAndSize(NULL, length))) {
! 	PyErr_SetString(PyExc_MemoryError,
! 			"Can't allocate memory to compress data");
  	return NULL;
-     }
  
      ENTER_ZLIB
--- 624,629 ----
      if (max_length && length > max_length) 
  	length = max_length;
!     if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
  	return NULL;
  
      ENTER_ZLIB
***************
*** 674,679 ****
  
  	if (_PyString_Resize(&RetVal, length) == -1) {
- 	    PyErr_SetString(PyExc_MemoryError,
- 			    "Can't allocate memory to compress data");
  	    return_error = 1;
  	    break;
--- 659,662 ----
***************
*** 710,715 ****
  		(char *)self->zst.next_in, self->zst.avail_in);
  	    if (self->unused_data == NULL) {
- 		PyErr_SetString(PyExc_MemoryError,
- 				"Can't allocate memory to unused_data");
  		Py_DECREF(RetVal);
  		return_error = 1;
--- 693,696 ----
***************
*** 770,778 ****
      }
  
!     if (!(RetVal = PyString_FromStringAndSize(NULL, length))) {
! 	PyErr_SetString(PyExc_MemoryError,
! 			"Can't allocate memory to compress data");
  	return NULL;
-     }
  
      ENTER_ZLIB
--- 751,756 ----
      }
  
!     if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
  	return NULL;
  
      ENTER_ZLIB
***************
*** 793,798 ****
      while (err == Z_OK && self->zst.avail_out == 0) {
  	if (_PyString_Resize(&RetVal, length << 1) == -1)  {
- 	    PyErr_SetString(PyExc_MemoryError,
- 			    "Can't allocate memory to compress data");
  	    return_error = 1;
  	    break;
--- 771,774 ----