diff options
author | Guido van Rossum <guido@python.org> | 2007-05-07 23:57:08 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-07 23:57:08 (GMT) |
commit | 617dbc4d643749804057f8dc7c52df702e40fe7a (patch) | |
tree | 6d8536fa856655cbcfa26404bbdbc495f97f7397 /Modules | |
parent | 805365ee39298f93e433e19ae0dd87c6f782145b (diff) | |
download | cpython-617dbc4d643749804057f8dc7c52df702e40fe7a.zip cpython-617dbc4d643749804057f8dc7c52df702e40fe7a.tar.gz cpython-617dbc4d643749804057f8dc7c52df702e40fe7a.tar.bz2 |
Checkpoint. A b it closer to working pickles and pickletools.
Added 'Y' getargs opcode which requires a bytes object.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/cPickle.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c index 9e3f8d1..00641d8 100644 --- a/Modules/cPickle.c +++ b/Modules/cPickle.c @@ -1335,7 +1335,8 @@ save_unicode(Picklerobject *self, PyObject *args, int doput) if (!( repr = PyUnicode_AsUTF8String(args))) return -1; - if ((size = PyString_Size(repr)) < 0) + assert(PyBytes_Check(repr)); + if ((size = PyBytes_Size(repr)) < 0) goto err; if (size > INT_MAX) return -1; /* string too large */ @@ -1354,7 +1355,7 @@ save_unicode(Picklerobject *self, PyObject *args, int doput) PDATA_APPEND(self->file, repr, -1); } else { - if (self->write_func(self, PyString_AS_STRING(repr), + if (self->write_func(self, PyBytes_AS_STRING(repr), size) < 0) goto err; } @@ -5275,8 +5276,11 @@ cpm_loads(PyObject *self, PyObject *args) PyObject *ob, *file = 0, *res = NULL; Unpicklerobject *unpickler = 0; - if (!( PyArg_ParseTuple(args, "S:loads", &ob))) - goto finally; + if (!( PyArg_ParseTuple(args, "S:loads", &ob))) { + PyErr_Clear(); + if (!PyArg_ParseTuple(args, "Y:loads", &ob)) + goto finally; + } if (!( file = PycStringIO->NewInput(ob))) goto finally; |