summaryrefslogtreecommitdiffstats
path: root/Python/marshal.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-04-13 03:31:13 (GMT)
committerGuido van Rossum <guido@python.org>2007-04-13 03:31:13 (GMT)
commit98f9746740e95bd0307a4a1a1f1adf69cc585e61 (patch)
tree66ce1f83cb22b87e627a4c2520055507a25c8cc8 /Python/marshal.c
parent84d79ddce2176ae54825da32e096d6332a8d5138 (diff)
downloadcpython-98f9746740e95bd0307a4a1a1f1adf69cc585e61.zip
cpython-98f9746740e95bd0307a4a1a1f1adf69cc585e61.tar.gz
cpython-98f9746740e95bd0307a4a1a1f1adf69cc585e61.tar.bz2
Support marshal.dump(x, f) where f is not a real file.
Support ord(b) where b is a 1-byte string. In zipfile.py, work around bytes being ints instead of chars, sometimes.
Diffstat (limited to 'Python/marshal.c')
-rw-r--r--Python/marshal.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index fd1bd72..2fb47e7 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -1062,9 +1062,14 @@ marshal_dump(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "OO|i:dump", &x, &f, &version))
return NULL;
if (!PyFile_Check(f)) {
- PyErr_SetString(PyExc_TypeError,
- "marshal.dump() 2nd arg must be file");
- return NULL;
+ /* XXX Quick hack -- need to do this differently */
+ PyObject *s = PyMarshal_WriteObjectToString(x, version);
+ PyObject *res = NULL;
+ if (s != NULL) {
+ res = PyObject_CallMethod(f, "write", "O", s);
+ Py_DECREF(s);
+ }
+ return res;
}
wf.fp = PyFile_AsFile(f);
wf.str = NULL;