diff Python/marshal.c @ 13106:a6725acdf33b legacy-trunk

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.)
author Guido van Rossum <guido@python.org>
date Wed, 28 Jun 2000 23:24:19 +0000
parents 7392e71f6cce
children 916fb024ce94
line wrap: on
line diff
--- a/Python/marshal.c	Wed Jun 28 22:55:20 2000 +0000
+++ b/Python/marshal.c	Wed Jun 28 23:24:19 2000 +0000
@@ -234,8 +234,9 @@
 	        PyObject *utf8;
 		utf8 = PyUnicode_AsUTF8String(v);
 		if (utf8 == NULL) {
-		    p->error = 1;
-		    return;
+			p->depth--;
+			p->error = 1;
+			return;
 		}
 		w_byte(TYPE_UNICODE, p);
 		n = PyString_GET_SIZE(utf8);
@@ -303,6 +304,8 @@
 		w_byte(TYPE_UNKNOWN, p);
 		p->error = 1;
 	}
+
+	p->depth--;
 }
 
 void
@@ -325,6 +328,7 @@
 	WFILE wf;
 	wf.fp = fp;
 	wf.error = 0;
+	wf.depth = 0;
 	w_object(x, &wf);
 }