mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
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.
This commit is contained in:
parent
84d79ddce2
commit
98f9746740
3 changed files with 27 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue