py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Python / marshal.c
blob008659ded6dc08ff20d669e0007ae895a05f4195
2 /* Write Python objects to files and read them back.
3 This is intended for writing and reading compiled Python code only;
4 a true persistent storage facility would be much harder, since
5 it would have to take circular links and sharing into account. */
7 #include "Python.h"
8 #include "longintrepr.h"
9 #include "compile.h"
10 #include "marshal.h"
12 /* High water mark to determine when the marshalled object is dangerously deep
13 * and risks coring the interpreter. When the object stack gets this deep,
14 * raise an exception instead of continuing.
16 #define MAX_MARSHAL_STACK_DEPTH 5000
18 #define TYPE_NULL '0'
19 #define TYPE_NONE 'N'
20 #define TYPE_STOPITER 'S'
21 #define TYPE_ELLIPSIS '.'
22 #define TYPE_INT 'i'
23 #define TYPE_INT64 'I'
24 #define TYPE_FLOAT 'f'
25 #define TYPE_COMPLEX 'x'
26 #define TYPE_LONG 'l'
27 #define TYPE_STRING 's'
28 #define TYPE_TUPLE '('
29 #define TYPE_LIST '['
30 #define TYPE_DICT '{'
31 #define TYPE_CODE 'c'
32 #define TYPE_UNICODE 'u'
33 #define TYPE_UNKNOWN '?'
35 typedef struct {
36 FILE *fp;
37 int error;
38 int depth;
39 /* If fp == NULL, the following are valid: */
40 PyObject *str;
41 char *ptr;
42 char *end;
43 } WFILE;
45 #define w_byte(c, p) if (((p)->fp)) putc((c), (p)->fp); \
46 else if ((p)->ptr != (p)->end) *(p)->ptr++ = (c); \
47 else w_more(c, p)
49 static void
50 w_more(int c, WFILE *p)
52 int size, newsize;
53 if (p->str == NULL)
54 return; /* An error already occurred */
55 size = PyString_Size(p->str);
56 newsize = size + 1024;
57 if (_PyString_Resize(&p->str, newsize) != 0) {
58 p->ptr = p->end = NULL;
60 else {
61 p->ptr = PyString_AS_STRING((PyStringObject *)p->str) + size;
62 p->end =
63 PyString_AS_STRING((PyStringObject *)p->str) + newsize;
64 *p->ptr++ = Py_SAFE_DOWNCAST(c, int, char);
68 static void
69 w_string(char *s, int n, WFILE *p)
71 if (p->fp != NULL) {
72 fwrite(s, 1, n, p->fp);
74 else {
75 while (--n >= 0) {
76 w_byte(*s, p);
77 s++;
82 static void
83 w_short(int x, WFILE *p)
85 w_byte( x & 0xff, p);
86 w_byte((x>> 8) & 0xff, p);
89 static void
90 w_long(long x, WFILE *p)
92 w_byte((int)( x & 0xff), p);
93 w_byte((int)((x>> 8) & 0xff), p);
94 w_byte((int)((x>>16) & 0xff), p);
95 w_byte((int)((x>>24) & 0xff), p);
98 #if SIZEOF_LONG > 4
99 static void
100 w_long64(long x, WFILE *p)
102 w_long(x, p);
103 w_long(x>>32, p);
105 #endif
107 static void
108 w_object(PyObject *v, WFILE *p)
110 int i, n;
111 PyBufferProcs *pb;
113 p->depth++;
115 if (p->depth > MAX_MARSHAL_STACK_DEPTH) {
116 p->error = 2;
118 else if (v == NULL) {
119 w_byte(TYPE_NULL, p);
121 else if (v == Py_None) {
122 w_byte(TYPE_NONE, p);
124 else if (v == PyExc_StopIteration) {
125 w_byte(TYPE_STOPITER, p);
127 else if (v == Py_Ellipsis) {
128 w_byte(TYPE_ELLIPSIS, p);
130 else if (PyInt_Check(v)) {
131 long x = PyInt_AS_LONG((PyIntObject *)v);
132 #if SIZEOF_LONG > 4
133 long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31);
134 if (y && y != -1) {
135 w_byte(TYPE_INT64, p);
136 w_long64(x, p);
138 else
139 #endif
141 w_byte(TYPE_INT, p);
142 w_long(x, p);
145 else if (PyLong_Check(v)) {
146 PyLongObject *ob = (PyLongObject *)v;
147 w_byte(TYPE_LONG, p);
148 n = ob->ob_size;
149 w_long((long)n, p);
150 if (n < 0)
151 n = -n;
152 for (i = 0; i < n; i++)
153 w_short(ob->ob_digit[i], p);
155 else if (PyFloat_Check(v)) {
156 char buf[256]; /* Plenty to format any double */
157 PyFloat_AsReprString(buf, (PyFloatObject *)v);
158 n = strlen(buf);
159 w_byte(TYPE_FLOAT, p);
160 w_byte(n, p);
161 w_string(buf, n, p);
163 #ifndef WITHOUT_COMPLEX
164 else if (PyComplex_Check(v)) {
165 char buf[256]; /* Plenty to format any double */
166 PyFloatObject *temp;
167 w_byte(TYPE_COMPLEX, p);
168 temp = (PyFloatObject*)PyFloat_FromDouble(
169 PyComplex_RealAsDouble(v));
170 PyFloat_AsReprString(buf, temp);
171 Py_DECREF(temp);
172 n = strlen(buf);
173 w_byte(n, p);
174 w_string(buf, n, p);
175 temp = (PyFloatObject*)PyFloat_FromDouble(
176 PyComplex_ImagAsDouble(v));
177 PyFloat_AsReprString(buf, temp);
178 Py_DECREF(temp);
179 n = strlen(buf);
180 w_byte(n, p);
181 w_string(buf, n, p);
183 #endif
184 else if (PyString_Check(v)) {
185 w_byte(TYPE_STRING, p);
186 n = PyString_GET_SIZE(v);
187 w_long((long)n, p);
188 w_string(PyString_AS_STRING(v), n, p);
190 else if (PyUnicode_Check(v)) {
191 PyObject *utf8;
192 utf8 = PyUnicode_AsUTF8String(v);
193 if (utf8 == NULL) {
194 p->depth--;
195 p->error = 1;
196 return;
198 w_byte(TYPE_UNICODE, p);
199 n = PyString_GET_SIZE(utf8);
200 w_long((long)n, p);
201 w_string(PyString_AS_STRING(utf8), n, p);
202 Py_DECREF(utf8);
204 else if (PyTuple_Check(v)) {
205 w_byte(TYPE_TUPLE, p);
206 n = PyTuple_Size(v);
207 w_long((long)n, p);
208 for (i = 0; i < n; i++) {
209 w_object(PyTuple_GET_ITEM(v, i), p);
212 else if (PyList_Check(v)) {
213 w_byte(TYPE_LIST, p);
214 n = PyList_GET_SIZE(v);
215 w_long((long)n, p);
216 for (i = 0; i < n; i++) {
217 w_object(PyList_GET_ITEM(v, i), p);
220 else if (PyDict_Check(v)) {
221 int pos;
222 PyObject *key, *value;
223 w_byte(TYPE_DICT, p);
224 /* This one is NULL object terminated! */
225 pos = 0;
226 while (PyDict_Next(v, &pos, &key, &value)) {
227 w_object(key, p);
228 w_object(value, p);
230 w_object((PyObject *)NULL, p);
232 else if (PyCode_Check(v)) {
233 PyCodeObject *co = (PyCodeObject *)v;
234 w_byte(TYPE_CODE, p);
235 w_short(co->co_argcount, p);
236 w_short(co->co_nlocals, p);
237 w_short(co->co_stacksize, p);
238 w_short(co->co_flags, p);
239 w_object(co->co_code, p);
240 w_object(co->co_consts, p);
241 w_object(co->co_names, p);
242 w_object(co->co_varnames, p);
243 w_object(co->co_freevars, p);
244 w_object(co->co_cellvars, p);
245 w_object(co->co_filename, p);
246 w_object(co->co_name, p);
247 w_short(co->co_firstlineno, p);
248 w_object(co->co_lnotab, p);
250 else if ((pb = v->ob_type->tp_as_buffer) != NULL &&
251 pb->bf_getsegcount != NULL &&
252 pb->bf_getreadbuffer != NULL &&
253 (*pb->bf_getsegcount)(v, NULL) == 1)
255 /* Write unknown buffer-style objects as a string */
256 char *s;
257 w_byte(TYPE_STRING, p);
258 n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s);
259 w_long((long)n, p);
260 w_string(s, n, p);
262 else {
263 w_byte(TYPE_UNKNOWN, p);
264 p->error = 1;
267 p->depth--;
270 void
271 PyMarshal_WriteLongToFile(long x, FILE *fp)
273 WFILE wf;
274 wf.fp = fp;
275 wf.error = 0;
276 wf.depth = 0;
277 w_long(x, &wf);
280 void
281 PyMarshal_WriteObjectToFile(PyObject *x, FILE *fp)
283 WFILE wf;
284 wf.fp = fp;
285 wf.error = 0;
286 wf.depth = 0;
287 w_object(x, &wf);
290 typedef WFILE RFILE; /* Same struct with different invariants */
292 #define rs_byte(p) (((p)->ptr != (p)->end) ? (unsigned char)*(p)->ptr++ : EOF)
294 #define r_byte(p) ((p)->fp ? getc((p)->fp) : rs_byte(p))
296 static int
297 r_string(char *s, int n, RFILE *p)
299 if (p->fp != NULL)
300 return fread(s, 1, n, p->fp);
301 if (p->end - p->ptr < n)
302 n = p->end - p->ptr;
303 memcpy(s, p->ptr, n);
304 p->ptr += n;
305 return n;
308 static int
309 r_short(RFILE *p)
311 register short x;
312 x = r_byte(p);
313 x |= r_byte(p) << 8;
314 /* Sign-extension, in case short greater than 16 bits */
315 x |= -(x & 0x8000);
316 return x;
319 static long
320 r_long(RFILE *p)
322 register long x;
323 register FILE *fp = p->fp;
324 if (fp) {
325 x = getc(fp);
326 x |= (long)getc(fp) << 8;
327 x |= (long)getc(fp) << 16;
328 x |= (long)getc(fp) << 24;
330 else {
331 x = rs_byte(p);
332 x |= (long)rs_byte(p) << 8;
333 x |= (long)rs_byte(p) << 16;
334 x |= (long)rs_byte(p) << 24;
336 #if SIZEOF_LONG > 4
337 /* Sign extension for 64-bit machines */
338 x |= -(x & 0x80000000L);
339 #endif
340 return x;
343 static long
344 r_long64(RFILE *p)
346 register long x;
347 x = r_long(p);
348 #if SIZEOF_LONG > 4
349 x = (x & 0xFFFFFFFFL) | (r_long(p) << 32);
350 #else
351 if (r_long(p) != 0) {
352 PyObject *f = PySys_GetObject("stderr");
353 if (f != NULL)
354 (void) PyFile_WriteString(
355 "Warning: un-marshal 64-bit int in 32-bit mode\n",
358 #endif
359 return x;
362 static PyObject *
363 r_object(RFILE *p)
365 PyObject *v, *v2;
366 long i, n;
367 int type = r_byte(p);
369 switch (type) {
371 case EOF:
372 PyErr_SetString(PyExc_EOFError,
373 "EOF read where object expected");
374 return NULL;
376 case TYPE_NULL:
377 return NULL;
379 case TYPE_NONE:
380 Py_INCREF(Py_None);
381 return Py_None;
383 case TYPE_STOPITER:
384 Py_INCREF(PyExc_StopIteration);
385 return PyExc_StopIteration;
387 case TYPE_ELLIPSIS:
388 Py_INCREF(Py_Ellipsis);
389 return Py_Ellipsis;
391 case TYPE_INT:
392 return PyInt_FromLong(r_long(p));
394 case TYPE_INT64:
395 return PyInt_FromLong(r_long64(p));
397 case TYPE_LONG:
399 int size;
400 PyLongObject *ob;
401 n = r_long(p);
402 size = n<0 ? -n : n;
403 ob = _PyLong_New(size);
404 if (ob == NULL)
405 return NULL;
406 ob->ob_size = n;
407 for (i = 0; i < size; i++)
408 ob->ob_digit[i] = r_short(p);
409 return (PyObject *)ob;
412 case TYPE_FLOAT:
414 char buf[256];
415 double dx;
416 n = r_byte(p);
417 if (r_string(buf, (int)n, p) != n) {
418 PyErr_SetString(PyExc_EOFError,
419 "EOF read where object expected");
420 return NULL;
422 buf[n] = '\0';
423 PyFPE_START_PROTECT("atof", return 0)
424 dx = atof(buf);
425 PyFPE_END_PROTECT(dx)
426 return PyFloat_FromDouble(dx);
429 #ifndef WITHOUT_COMPLEX
430 case TYPE_COMPLEX:
432 char buf[256];
433 Py_complex c;
434 n = r_byte(p);
435 if (r_string(buf, (int)n, p) != n) {
436 PyErr_SetString(PyExc_EOFError,
437 "EOF read where object expected");
438 return NULL;
440 buf[n] = '\0';
441 PyFPE_START_PROTECT("atof", return 0)
442 c.real = atof(buf);
443 PyFPE_END_PROTECT(c)
444 n = r_byte(p);
445 if (r_string(buf, (int)n, p) != n) {
446 PyErr_SetString(PyExc_EOFError,
447 "EOF read where object expected");
448 return NULL;
450 buf[n] = '\0';
451 PyFPE_START_PROTECT("atof", return 0)
452 c.imag = atof(buf);
453 PyFPE_END_PROTECT(c)
454 return PyComplex_FromCComplex(c);
456 #endif
458 case TYPE_STRING:
459 n = r_long(p);
460 if (n < 0) {
461 PyErr_SetString(PyExc_ValueError, "bad marshal data");
462 return NULL;
464 v = PyString_FromStringAndSize((char *)NULL, n);
465 if (v != NULL) {
466 if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
467 Py_DECREF(v);
468 v = NULL;
469 PyErr_SetString(PyExc_EOFError,
470 "EOF read where object expected");
473 return v;
475 case TYPE_UNICODE:
477 char *buffer;
479 n = r_long(p);
480 if (n < 0) {
481 PyErr_SetString(PyExc_ValueError, "bad marshal data");
482 return NULL;
484 buffer = PyMem_NEW(char, n);
485 if (buffer == NULL)
486 return PyErr_NoMemory();
487 if (r_string(buffer, (int)n, p) != n) {
488 PyMem_DEL(buffer);
489 PyErr_SetString(PyExc_EOFError,
490 "EOF read where object expected");
491 return NULL;
493 v = PyUnicode_DecodeUTF8(buffer, n, NULL);
494 PyMem_DEL(buffer);
495 return v;
498 case TYPE_TUPLE:
499 n = r_long(p);
500 if (n < 0) {
501 PyErr_SetString(PyExc_ValueError, "bad marshal data");
502 return NULL;
504 v = PyTuple_New((int)n);
505 if (v == NULL)
506 return v;
507 for (i = 0; i < n; i++) {
508 v2 = r_object(p);
509 if ( v2 == NULL ) {
510 Py_DECREF(v);
511 v = NULL;
512 break;
514 PyTuple_SET_ITEM(v, (int)i, v2);
516 return v;
518 case TYPE_LIST:
519 n = r_long(p);
520 if (n < 0) {
521 PyErr_SetString(PyExc_ValueError, "bad marshal data");
522 return NULL;
524 v = PyList_New((int)n);
525 if (v == NULL)
526 return v;
527 for (i = 0; i < n; i++) {
528 v2 = r_object(p);
529 if ( v2 == NULL ) {
530 Py_DECREF(v);
531 v = NULL;
532 break;
534 PyList_SetItem(v, (int)i, v2);
536 return v;
538 case TYPE_DICT:
539 v = PyDict_New();
540 if (v == NULL)
541 return NULL;
542 for (;;) {
543 PyObject *key, *val;
544 key = r_object(p);
545 if (key == NULL)
546 break; /* XXX Assume TYPE_NULL, not an error */
547 val = r_object(p);
548 if (val != NULL)
549 PyDict_SetItem(v, key, val);
550 Py_DECREF(key);
551 Py_XDECREF(val);
553 return v;
555 case TYPE_CODE:
557 int argcount = r_short(p);
558 int nlocals = r_short(p);
559 int stacksize = r_short(p);
560 int flags = r_short(p);
561 PyObject *code = NULL;
562 PyObject *consts = NULL;
563 PyObject *names = NULL;
564 PyObject *varnames = NULL;
565 PyObject *freevars = NULL;
566 PyObject *cellvars = NULL;
567 PyObject *filename = NULL;
568 PyObject *name = NULL;
569 int firstlineno = 0;
570 PyObject *lnotab = NULL;
572 code = r_object(p);
573 if (code) consts = r_object(p);
574 if (consts) names = r_object(p);
575 if (names) varnames = r_object(p);
576 if (varnames) freevars = r_object(p);
577 if (freevars) cellvars = r_object(p);
578 if (cellvars) filename = r_object(p);
579 if (filename) name = r_object(p);
580 if (name) {
581 firstlineno = r_short(p);
582 lnotab = r_object(p);
585 if (!PyErr_Occurred()) {
586 v = (PyObject *) PyCode_New(
587 argcount, nlocals, stacksize, flags,
588 code, consts, names, varnames,
589 freevars, cellvars, filename, name,
590 firstlineno, lnotab);
592 else
593 v = NULL;
594 Py_XDECREF(code);
595 Py_XDECREF(consts);
596 Py_XDECREF(names);
597 Py_XDECREF(varnames);
598 Py_XDECREF(freevars);
599 Py_XDECREF(cellvars);
600 Py_XDECREF(filename);
601 Py_XDECREF(name);
602 Py_XDECREF(lnotab);
605 return v;
607 default:
608 /* Bogus data got written, which isn't ideal.
609 This will let you keep working and recover. */
610 PyErr_SetString(PyExc_ValueError, "bad marshal data");
611 return NULL;
616 long
617 PyMarshal_ReadLongFromFile(FILE *fp)
619 RFILE rf;
620 rf.fp = fp;
621 return r_long(&rf);
624 #ifdef HAVE_FSTAT
625 /* Return size of file in bytes; < 0 if unknown. */
626 static off_t
627 getfilesize(FILE *fp)
629 struct stat st;
630 if (fstat(fileno(fp), &st) != 0)
631 return -1;
632 else
633 return st.st_size;
635 #endif
637 /* If we can get the size of the file up-front, and it's reasonably small,
638 * read it in one gulp and delegate to ...FromString() instead. Much quicker
639 * than reading a byte at a time from file; speeds .pyc imports.
640 * CAUTION: since this may read the entire remainder of the file, don't
641 * call it unless you know you're done with the file.
643 PyObject *
644 PyMarshal_ReadLastObjectFromFile(FILE *fp)
646 /* 75% of 2.1's .pyc files can exploit SMALL_FILE_LIMIT.
647 * REASONABLE_FILE_LIMIT is by defn something big enough for Tkinter.pyc.
649 #define SMALL_FILE_LIMIT (1L << 14)
650 #define REASONABLE_FILE_LIMIT (1L << 18)
651 #ifdef HAVE_FSTAT
652 off_t filesize;
653 #endif
654 if (PyErr_Occurred()) {
655 fprintf(stderr, "XXX rd_object called with exception set\n");
656 return NULL;
658 #ifdef HAVE_FSTAT
659 filesize = getfilesize(fp);
660 if (filesize > 0) {
661 char buf[SMALL_FILE_LIMIT];
662 char* pBuf = NULL;
663 if (filesize <= SMALL_FILE_LIMIT)
664 pBuf = buf;
665 else if (filesize <= REASONABLE_FILE_LIMIT)
666 pBuf = (char *)PyMem_MALLOC(filesize);
667 if (pBuf != NULL) {
668 PyObject* v;
669 size_t n = fread(pBuf, 1, filesize, fp);
670 v = PyMarshal_ReadObjectFromString(pBuf, n);
671 if (pBuf != buf)
672 PyMem_FREE(pBuf);
673 return v;
677 #endif
678 /* We don't have fstat, or we do but the file is larger than
679 * REASONABLE_FILE_LIMIT or malloc failed -- read a byte at a time.
681 return PyMarshal_ReadObjectFromFile(fp);
683 #undef SMALL_FILE_LIMIT
684 #undef REASONABLE_FILE_LIMIT
687 PyObject *
688 PyMarshal_ReadObjectFromFile(FILE *fp)
690 RFILE rf;
691 if (PyErr_Occurred()) {
692 fprintf(stderr, "XXX rd_object called with exception set\n");
693 return NULL;
695 rf.fp = fp;
696 return r_object(&rf);
699 PyObject *
700 PyMarshal_ReadObjectFromString(char *str, int len)
702 RFILE rf;
703 if (PyErr_Occurred()) {
704 fprintf(stderr, "XXX rds_object called with exception set\n");
705 return NULL;
707 rf.fp = NULL;
708 rf.str = NULL;
709 rf.ptr = str;
710 rf.end = str + len;
711 return r_object(&rf);
714 PyObject *
715 PyMarshal_WriteObjectToString(PyObject *x) /* wrs_object() */
717 WFILE wf;
718 wf.fp = NULL;
719 wf.str = PyString_FromStringAndSize((char *)NULL, 50);
720 if (wf.str == NULL)
721 return NULL;
722 wf.ptr = PyString_AS_STRING((PyStringObject *)wf.str);
723 wf.end = wf.ptr + PyString_Size(wf.str);
724 wf.error = 0;
725 wf.depth = 0;
726 w_object(x, &wf);
727 if (wf.str != NULL)
728 _PyString_Resize(&wf.str,
729 (int) (wf.ptr -
730 PyString_AS_STRING((PyStringObject *)wf.str)));
731 if (wf.error) {
732 Py_XDECREF(wf.str);
733 PyErr_SetString(PyExc_ValueError,
734 (wf.error==1)?"unmarshallable object"
735 :"object too deeply nested to marshal");
736 return NULL;
738 return wf.str;
741 /* And an interface for Python programs... */
743 static PyObject *
744 marshal_dump(PyObject *self, PyObject *args)
746 WFILE wf;
747 PyObject *x;
748 PyObject *f;
749 if (!PyArg_ParseTuple(args, "OO:dump", &x, &f))
750 return NULL;
751 if (!PyFile_Check(f)) {
752 PyErr_SetString(PyExc_TypeError,
753 "marshal.dump() 2nd arg must be file");
754 return NULL;
756 wf.fp = PyFile_AsFile(f);
757 wf.str = NULL;
758 wf.ptr = wf.end = NULL;
759 wf.error = 0;
760 wf.depth = 0;
761 w_object(x, &wf);
762 if (wf.error) {
763 PyErr_SetString(PyExc_ValueError,
764 (wf.error==1)?"unmarshallable object"
765 :"object too deeply nested to marshal");
766 return NULL;
768 Py_INCREF(Py_None);
769 return Py_None;
772 static PyObject *
773 marshal_load(PyObject *self, PyObject *args)
775 RFILE rf;
776 PyObject *f;
777 PyObject *v;
778 if (!PyArg_ParseTuple(args, "O:load", &f))
779 return NULL;
780 if (!PyFile_Check(f)) {
781 PyErr_SetString(PyExc_TypeError,
782 "marshal.load() arg must be file");
783 return NULL;
785 rf.fp = PyFile_AsFile(f);
786 rf.str = NULL;
787 rf.ptr = rf.end = NULL;
788 PyErr_Clear();
789 v = r_object(&rf);
790 if (PyErr_Occurred()) {
791 Py_XDECREF(v);
792 v = NULL;
794 return v;
797 static PyObject *
798 marshal_dumps(PyObject *self, PyObject *args)
800 PyObject *x;
801 if (!PyArg_ParseTuple(args, "O:dumps", &x))
802 return NULL;
803 return PyMarshal_WriteObjectToString(x);
806 static PyObject *
807 marshal_loads(PyObject *self, PyObject *args)
809 RFILE rf;
810 PyObject *v;
811 char *s;
812 int n;
813 if (!PyArg_ParseTuple(args, "s#:loads", &s, &n))
814 return NULL;
815 rf.fp = NULL;
816 rf.str = args;
817 rf.ptr = s;
818 rf.end = s + n;
819 PyErr_Clear();
820 v = r_object(&rf);
821 if (PyErr_Occurred()) {
822 Py_XDECREF(v);
823 v = NULL;
825 return v;
828 static PyMethodDef marshal_methods[] = {
829 {"dump", marshal_dump, 1},
830 {"load", marshal_load, 1},
831 {"dumps", marshal_dumps, 1},
832 {"loads", marshal_loads, 1},
833 {NULL, NULL} /* sentinel */
836 void
837 PyMarshal_Init(void)
839 (void) Py_InitModule("marshal", marshal_methods);