cpython: 42dd11028e94 (original) (raw)

--- a/Lib/importlib/test/source/test_file_loader.py +++ b/Lib/importlib/test/source/test_file_loader.py @@ -214,7 +214,7 @@ class BadBytecodeTest(unittest.TestCase) lambda bc: bc[:8] + b'', del_source=del_source) file_path = mapping['_temp'] if not del_source else bytecode_path

def _test_bad_magic(self, test, *, del_source=False):

--- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -228,6 +228,30 @@ class BugsTestCase(unittest.TestCase): invalid_string = b'l\x02\x00\x00\x00\x00\x00\x00\x00' self.assertRaises(ValueError, marshal.loads, invalid_string)

+ def test_main(): support.run_unittest(IntTestCase,

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1? Core and Builtins ----------------- +- Issue #12291: You can now load multiple marshalled objects from a stream,

--- a/Python/marshal.c +++ b/Python/marshal.c @@ -57,6 +57,7 @@ typedef struct { int error; /* see WFERR_* values / int depth; / If fp == NULL, the following are valid: */

#define rs_byte(p) (((p)->ptr < (p)->end) ? (unsigned char)*(p)->ptr++ : EOF) -#define r_byte(p) ((p)->fp ? getc((p)->fp) : rs_byte(p)) - static int r_string(char *s, int n, RFILE *p) {

+

+} + + +static int +r_byte(RFILE *p) +{

+

} static int r_short(RFILE *p) { register short x;

+

+

#if SIZEOF_LONG > 4 /* Sign extension for 64-bit machines */ x |= -(x & 0x80000000L); @@ -523,25 +566,30 @@ r_long(RFILE *p) static PyObject * r_long64(RFILE *p) {

#if SIZEOF_LONG > 4

#else

+#endif }

-#endif

} static PyObject * @@ -553,6 +601,8 @@ r_PyLong(RFILE *p) digit d; n = r_long(p);

@@ -581,6 +633,8 @@ r_PyLong(RFILE *p) d = 0; for (j=0; j < shorts_in_top_digit; j++) { md = r_short(p);

@@ -592,6 +646,10 @@ r_PyLong(RFILE p) } d += (digit)md << jPyLong_MARSHAL_SHIFT; }

case TYPE_INT:

case TYPE_INT64: @@ -770,6 +829,10 @@ r_object(RFILE *p) case TYPE_STRING: n = r_long(p);

@@ -795,6 +858,10 @@ r_object(RFILE *p) char *buffer; n = r_long(p);

@@ -820,6 +887,10 @@ r_object(RFILE *p) case TYPE_TUPLE: n = r_long(p);

@@ -847,6 +918,10 @@ r_object(RFILE *p) case TYPE_LIST: n = r_long(p);

@@ -899,6 +974,10 @@ r_object(RFILE *p) case TYPE_SET: case TYPE_FROZENSET: n = r_long(p);

@@ -952,10 +1031,20 @@ r_object(RFILE p) / XXX ignore long->int overflows for now */ argcount = (int)r_long(p);

@@ -1049,6 +1138,7 @@ PyMarshal_ReadShortFromFile(FILE *fp) { RFILE rf; assert(fp);

@@ -1224,32 +1318,33 @@ The version argument indicates the data static PyObject * marshal_load(PyObject *self, PyObject *f) {

+

@@ -1300,6 +1395,7 @@ marshal_loads(PyObject *self, PyObject * s = p.buf; n = p.len; rf.fp = NULL;