diff options
author | Guido van Rossum <guido@python.org> | 2006-08-17 22:28:49 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2006-08-17 22:28:49 (GMT) |
commit | 512ab9f8d34e450d5ee35e264dc29004b08d7b73 (patch) | |
tree | 783c2bb37a72de79f240171df1efe71a5606dd3c | |
parent | 49d6b07c6b4b16d35f160726a59de819d077ee30 (diff) | |
download | cpython-512ab9f8d34e450d5ee35e264dc29004b08d7b73.zip cpython-512ab9f8d34e450d5ee35e264dc29004b08d7b73.tar.gz cpython-512ab9f8d34e450d5ee35e264dc29004b08d7b73.tar.bz2 |
Fixed cPickle, by restoring some of the deleted code.
-This line, and those below, will be ignored--
M setup.py
M Modules/cPickle.c
-rw-r--r-- | Modules/cPickle.c | 43 | ||||
-rw-r--r-- | setup.py | 2 |
2 files changed, 41 insertions, 4 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c index d6b4581..fabc3cd 100644 --- a/Modules/cPickle.c +++ b/Modules/cPickle.c @@ -1786,7 +1786,6 @@ save_dict(Picklerobject *self, PyObject *args) } - static int save_global(Picklerobject *self, PyObject *args, PyObject *name) { @@ -2278,6 +2277,12 @@ save(Picklerobject *self, PyObject *args, int pers_save) } break; + case 'i': + break; + + case 'c': + break; + case 'f': if (type == &PyFunction_Type) { res = save_global(self, args, NULL); @@ -3438,6 +3443,30 @@ load_dict(Unpicklerobject *self) return 0; } +static PyObject * +Instance_New(PyObject *cls, PyObject *args) +{ + PyObject *r = 0; + + if ((r=PyObject_CallObject(cls, args))) return r; + + { + PyObject *tp, *v, *tb, *tmp_value; + + PyErr_Fetch(&tp, &v, &tb); + tmp_value = v; + /* NULL occurs when there was a KeyboardInterrupt */ + if (tmp_value == NULL) + tmp_value = Py_None; + if ((r = PyTuple_Pack(3, tmp_value, cls, args))) { + Py_XDECREF(v); + v=r; + } + PyErr_Restore(tp,v,tb); + } + return NULL; +} + static int load_obj(Unpicklerobject *self) @@ -3448,6 +3477,10 @@ load_obj(Unpicklerobject *self) if ((i = marker(self)) < 0) return -1; if (!( tup=Pdata_popTuple(self->stack, i+1))) return -1; PDATA_POP(self->stack, class); + if (class) { + obj = Instance_New(class, tup); + Py_DECREF(class); + } Py_DECREF(tup); if (! obj) return -1; @@ -3483,8 +3516,8 @@ load_inst(Unpicklerobject *self) if (! class) return -1; if ((tup=Pdata_popTuple(self->stack, i))) { - PyErr_SetString(UnpicklingError, "it's dead, Jim"); - return -1; + obj = Instance_New(class, tup); + Py_DECREF(tup); } Py_DECREF(class); @@ -4177,6 +4210,10 @@ load_reduce(Unpicklerobject *self) PDATA_POP(self->stack, arg_tup); if (! arg_tup) return -1; PDATA_POP(self->stack, callable); + if (callable) { + ob = Instance_New(callable, arg_tup); + Py_DECREF(callable); + } Py_DECREF(arg_tup); if (! ob) return -1; @@ -430,7 +430,7 @@ class PyBuildExt(build_ext): # cStringIO and cPickle exts.append( Extension('cStringIO', ['cStringIO.c']) ) - ##exts.append( Extension('cPickle', ['cPickle.c']) ) + exts.append( Extension('cPickle', ['cPickle.c']) ) # Memory-mapped files (also works on Win32). if platform not in ['atheos', 'mac']: |