[Python-checkins] CVS: python/dist/src/Python marshal.c,1.48,1.49

Guido van Rossum python-dev@python.org
Wed, 28 Jun 2000 16:24:21 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv23333

Modified Files:
	marshal.c 
Log Message:
Urmpf.  Quality control on this patch lapsed a bit. :-(

The depth field was never decremented inside w_object(), and it was
never initialized in PyMarshal_WriteObjectToFile().

This caused imports from .pyc files to fil mysteriously when the .pyc
file was written by the broken code -- w_object() would bail out
early, but PyMarshal_WriteObjectToFile() doesn't check the error or
return an error code, and apparently the marshalling code doesn't call
PyErr_Check() either.  (That's a separate patch if I feel like it.)


Index: marshal.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -r1.48 -r1.49
*** marshal.c	2000/06/28 18:47:56	1.48
--- marshal.c	2000/06/28 23:24:19	1.49
***************
*** 235,240 ****
  		utf8 = PyUnicode_AsUTF8String(v);
  		if (utf8 == NULL) {
! 		    p->error = 1;
! 		    return;
  		}
  		w_byte(TYPE_UNICODE, p);
--- 235,241 ----
  		utf8 = PyUnicode_AsUTF8String(v);
  		if (utf8 == NULL) {
! 			p->depth--;
! 			p->error = 1;
! 			return;
  		}
  		w_byte(TYPE_UNICODE, p);
***************
*** 304,307 ****
--- 305,310 ----
  		p->error = 1;
  	}
+ 
+ 	p->depth--;
  }
  
***************
*** 326,329 ****
--- 329,333 ----
  	wf.fp = fp;
  	wf.error = 0;
+ 	wf.depth = 0;
  	w_object(x, &wf);
  }