Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98626cd

Browse files
committed
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.)
1 parent a04ff0f commit 98626cd

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Python/marshal.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ w_object(v, p)
234234
PyObject *utf8;
235235
utf8 = PyUnicode_AsUTF8String(v);
236236
if (utf8 == NULL) {
237-
p->error = 1;
238-
return;
237+
p->depth--;
238+
p->error = 1;
239+
return;
239240
}
240241
w_byte(TYPE_UNICODE, p);
241242
n = PyString_GET_SIZE(utf8);
@@ -303,6 +304,8 @@ w_object(v, p)
303304
w_byte(TYPE_UNKNOWN, p);
304305
p->error = 1;
305306
}
307+
308+
p->depth--;
306309
}
307310

308311
void
@@ -325,6 +328,7 @@ PyMarshal_WriteObjectToFile(x, fp)
325328
WFILE wf;
326329
wf.fp = fp;
327330
wf.error = 0;
331+
wf.depth = 0;
328332
w_object(x, &wf);
329333
}
330334

0 commit comments

Comments
 (0)