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.)
This commit is contained in:
Guido van Rossum 2000-06-28 23:24:19 +00:00
parent a04ff0fb53
commit 98626cd7ac
1 changed files with 6 additions and 2 deletions

View File

@ -234,8 +234,9 @@ w_object(v, p)
PyObject *utf8; PyObject *utf8;
utf8 = PyUnicode_AsUTF8String(v); utf8 = PyUnicode_AsUTF8String(v);
if (utf8 == NULL) { if (utf8 == NULL) {
p->error = 1; p->depth--;
return; p->error = 1;
return;
} }
w_byte(TYPE_UNICODE, p); w_byte(TYPE_UNICODE, p);
n = PyString_GET_SIZE(utf8); n = PyString_GET_SIZE(utf8);
@ -303,6 +304,8 @@ w_object(v, p)
w_byte(TYPE_UNKNOWN, p); w_byte(TYPE_UNKNOWN, p);
p->error = 1; p->error = 1;
} }
p->depth--;
} }
void void
@ -325,6 +328,7 @@ PyMarshal_WriteObjectToFile(x, fp)
WFILE wf; WFILE wf;
wf.fp = fp; wf.fp = fp;
wf.error = 0; wf.error = 0;
wf.depth = 0;
w_object(x, &wf); w_object(x, &wf);
} }