[Python-3000-checkins] r51345 - in python/branches/p3yk: Modules/cPickle.c setup.py
guido.van.rossum
python-3000-checkins at python.org
Fri Aug 18 00:28:50 CEST 2006
Author: guido.van.rossum
Date: Fri Aug 18 00:28:49 2006
New Revision: 51345
Modified:
python/branches/p3yk/Modules/cPickle.c
python/branches/p3yk/setup.py
Log:
Fixed cPickle, by restoring some of the deleted code.
-This line, and those below, will be ignored--
M setup.py
M Modules/cPickle.c
Modified: python/branches/p3yk/Modules/cPickle.c
==============================================================================
--- python/branches/p3yk/Modules/cPickle.c (original)
+++ python/branches/p3yk/Modules/cPickle.c Fri Aug 18 00:28:49 2006
@@ -1786,7 +1786,6 @@
}
-
static int
save_global(Picklerobject *self, PyObject *args, PyObject *name)
{
@@ -2278,6 +2277,12 @@
}
break;
+ case 'i':
+ break;
+
+ case 'c':
+ break;
+
case 'f':
if (type == &PyFunction_Type) {
res = save_global(self, args, NULL);
@@ -3438,6 +3443,30 @@
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 @@
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 @@
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 @@
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;
Modified: python/branches/p3yk/setup.py
==============================================================================
--- python/branches/p3yk/setup.py (original)
+++ python/branches/p3yk/setup.py Fri Aug 18 00:28:49 2006
@@ -430,7 +430,7 @@
# 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']:
More information about the Python-3000-checkins
mailing list