/*
* cPickle.c,v 1.71 1999/07/11 13:30:34 jim Exp
- *
- * Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
+ *
+ * Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* o Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the disclaimer that follows.
- *
+ *
* o Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- *
+ *
* o Neither the name of Digital Creations nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS
* IS* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
- *
- #
+ *
+ #
# If you have questions regarding this software, contact:
#
# Digital Creations, L.C.
# (540) 371-6909
*/
-static char cPickle_module_documentation[] =
+static char cPickle_module_documentation[] =
"C implementation and optimization of the Python pickle module\n"
"\n"
"cPickle.c,v 1.71 1999/07/11 13:30:34 jim Exp\n"
PyObject **data;
} Pdata;
-static void
+static void
Pdata_dealloc(Pdata *self) {
int i;
PyObject **p;
return PyErr_NoMemory();
}
-static int
+static int
stackUnderflow(void) {
PyErr_SetString(UnpicklingError, "unpickling stack underflow");
return -1;
}
-static int
+static int
Pdata_grow(Pdata *self) {
if (! self->size) {
PyErr_NoMemory();
return -1;
}
- self->size *= 2;
+ self->size *= 2;
self->data = realloc(self->data, self->size*sizeof(PyObject*));
if (! self->data) {
- self->size = 0;
- PyErr_NoMemory();
- return -1;
+ self->size = 0;
+ PyErr_NoMemory();
+ return -1;
}
return 0;
-}
+}
#define PDATA_POP(D,V) { \
if ((D)->length) V=D->data[--((D)->length)]; \
PyObject *safe_constructors;
PyObject *find_class;
} Unpicklerobject;
-
+
staticforward PyTypeObject Unpicklertype;
/* Forward decls that need the above structs */
static int save(Picklerobject *, PyObject *, int);
static int put2(Picklerobject *, PyObject *);
-int
+int
cPickle_PyMapping_HasKey(PyObject *o, PyObject *key) {
PyObject *v;
va_list va;
PyObject *args=0, *retval=0;
va_start(va, format);
-
+
if (format) args = Py_VaBuildValue(format, va);
va_end(va);
if (format && ! args) return NULL;
return NULL;
}
-static int
+static int
write_file(Picklerobject *self, char *s, int n) {
+ size_t nbyteswritten;
+
if (s == NULL) {
return 0;
}
- if (fwrite(s, sizeof(char), n, self->fp) != (size_t)n) {
+ Py_BEGIN_ALLOW_THREADS
+ nbyteswritten = fwrite(s, sizeof(char), n, self->fp);
+ Py_END_ALLOW_THREADS
+ if (nbyteswritten != (size_t)n) {
PyErr_SetFromErrno(PyExc_IOError);
return -1;
}
return n;
}
-static int
+static int
write_cStringIO(Picklerobject *self, char *s, int n) {
if (s == NULL) {
return 0;
return n;
}
-static int
+static int
write_none(Picklerobject *self, char *s, int n) {
if (s == NULL) return 0;
return n;
}
-static int
+static int
write_other(Picklerobject *self, char *s, int n) {
PyObject *py_str = 0, *junk = 0;
if (s == NULL) {
UNLESS (self->buf_size) return 0;
- UNLESS (py_str =
+ UNLESS (py_str =
PyString_FromStringAndSize(self->write_buf, self->buf_size))
return -1;
}
return -1;
}
- if (n > WRITE_BUF_SIZE) {
- UNLESS (py_str =
+ if (n > WRITE_BUF_SIZE) {
+ UNLESS (py_str =
PyString_FromStringAndSize(s, n))
return -1;
}
if (junk) Py_DECREF(junk);
else return -1;
}
- else
+ else
PDATA_PUSH(self->file, py_str, -1);
-
- self->buf_size = 0;
+
+ self->buf_size = 0;
return n;
}
-static int
+static int
read_file(Unpicklerobject *self, char **s, int n) {
+ size_t nbytesread;
if (self->buf_size == 0) {
int size;
- size = ((n < 32) ? 32 : n);
+ size = ((n < 32) ? 32 : n);
UNLESS (self->buf = (char *)malloc(size * sizeof(char))) {
PyErr_NoMemory();
return -1;
PyErr_NoMemory();
return -1;
}
-
+
self->buf_size = n;
}
-
- if (fread(self->buf, sizeof(char), n, self->fp) != (size_t)n) {
+
+ Py_BEGIN_ALLOW_THREADS
+ nbytesread = fread(self->buf, sizeof(char), n, self->fp);
+ Py_END_ALLOW_THREADS
+ if (nbytesread != (size_t)n) {
if (feof(self->fp)) {
PyErr_SetNone(PyExc_EOFError);
return -1;
}
-static int
+static int
readline_file(Unpicklerobject *self, char **s) {
int i;
PyErr_NoMemory();
return -1;
}
-
+
self->buf_size = 40;
}
}
}
- UNLESS (self->buf = (char *)realloc(self->buf,
+ UNLESS (self->buf = (char *)realloc(self->buf,
(self->buf_size * 2) * sizeof(char))) {
PyErr_NoMemory();
return -1;
self->buf_size *= 2;
}
-}
+}
-static int
+static int
read_cStringIO(Unpicklerobject *self, char **s, int n) {
char *ptr;
}
-static int
+static int
readline_cStringIO(Unpicklerobject *self, char **s) {
int n;
char *ptr;
}
-static int
+static int
read_other(Unpicklerobject *self, char **s, int n) {
PyObject *bytes, *str=0;
}
-static int
+static int
readline_other(Unpicklerobject *self, char **s) {
PyObject *str;
int str_size;
UNLESS (value = PyTuple_GetItem(mv, 0))
return -1;
-
+
UNLESS (PyInt_Check(value)) {
PyErr_SetString(PicklingError, "no int where int expected in memo");
return -1;
return 0;
}
-
+
static int
put(Picklerobject *self, PyObject *ob) {
return put2(self, ob);
}
-
+
static int
put2(Picklerobject *self, PyObject *ob) {
char c_str[30];
else {
c_str[0] = BINPUT;
c_str[1] = p;
- len = 2;
+ len = 2;
}
}
UNLESS (standard_builtins ||
(standard_builtins=PyImport_ImportModule("__builtin__")))
return NULL;
-
+
__builtins__=standard_builtins;
Py_INCREF(__builtins__);
UNLESS (globals = Py_BuildValue("{sO}", "__builtins__", __builtins__))
Py_DECREF(globals);
Py_DECREF(__builtins__);
Py_DECREF(__import__);
-
+
return r;
err:
Py_XDECREF(globals);
while ((j = PyDict_Next(modules_dict, &i, &name, &module))) {
if (PyObject_Compare(name, __main___str)==0) continue;
-
+
UNLESS (global_name_attr = PyObject_GetAttr(module, global_name)) {
PyErr_Clear();
continue;
static int
save_none(Picklerobject *self, PyObject *args) {
static char none = NONE;
- if ((*self->write_func)(self, &none, 1) < 0)
+ if ((*self->write_func)(self, &none, 1) < 0)
return -1;
return 0;
}
-
+
static int
save_int(Picklerobject *self, PyObject *args) {
char c_str[32];
if ((*self->write_func)(self, &l, 1) < 0)
goto finally;
- if ((*self->write_func)(self,
+ if ((*self->write_func)(self,
PyString_AS_STRING((PyStringObject *)repr), size) < 0)
goto finally;
PDATA_APPEND(self->file, args, -1);
}
else {
- if ((*self->write_func)(self,
+ if ((*self->write_func)(self,
PyString_AS_STRING((PyStringObject *)args), size) < 0)
return -1;
}
if ((*self->write_func)(self, &MARKv, 1) < 0)
goto finally;
- if ((len = PyTuple_Size(args)) < 0)
+ if ((len = PyTuple_Size(args)) < 0)
goto finally;
for (i = 0; i < len; i++) {
- UNLESS (element = PyTuple_GET_ITEM((PyTupleObject *)args, i))
+ UNLESS (element = PyTuple_GET_ITEM((PyTupleObject *)args, i))
goto finally;
-
+
if (save(self, element, 0) < 0)
goto finally;
}
if (has_key) {
if (self->bin) {
static char pop_mark = POP_MARK;
-
+
if ((*self->write_func)(self, &pop_mark, 1) < 0)
goto finally;
}
else {
static char pop = POP;
-
+
for (i = 0; i <= len; i++) {
if ((*self->write_func)(self, &pop, 1) < 0)
goto finally;
- }
+ }
}
-
+
if (get(self, py_tuple_id) < 0)
goto finally;
if (put(self, args) < 0)
goto finally;
-
+
res = 0;
finally:
if (self->bin) {
s[0] = EMPTY_LIST;
s_len = 1;
- }
+ }
else {
s[0] = MARK;
s[1] = LIST;
goto finally;
for (i = 0; i < len; i++) {
- UNLESS (element = PyList_GET_ITEM((PyListObject *)args, i))
+ UNLESS (element = PyList_GET_ITEM((PyListObject *)args, i))
goto finally;
- if (save(self, element, 0) < 0)
- goto finally;
+ if (save(self, element, 0) < 0)
+ goto finally;
if (!using_appends) {
if ((*self->write_func)(self, &append, 1) < 0)
}
-static int
+static int
save_inst(Picklerobject *self, PyObject *args) {
- PyObject *class = 0, *module = 0, *name = 0, *state = 0,
+ PyObject *class = 0, *module = 0, *name = 0, *state = 0,
*getinitargs_func = 0, *getstate_func = 0, *class_args = 0;
char *module_str, *name_str;
int module_size, name_size, res = -1;
PyObject *element = 0;
int i, len;
- UNLESS (class_args =
+ UNLESS (class_args =
PyObject_CallObject(getinitargs_func, empty_tuple))
goto finally;
- if ((len = PyObject_Size(class_args)) < 0)
+ if ((len = PyObject_Size(class_args)) < 0)
goto finally;
for (i = 0; i < len; i++) {
- UNLESS (element = PySequence_GetItem(class_args, i))
+ UNLESS (element = PySequence_GetItem(class_args, i))
goto finally;
if (save(self, element, 0) < 0) {
UNLESS (module = whichmodule(class, name))
goto finally;
-
+
if ((module_size = PyString_Size(module)) < 0 ||
(name_size = PyString_Size(name)) < 0)
goto finally;
if (put(self, args) < 0)
goto finally;
}
-
+
if (save(self, state, 0) < 0)
goto finally;
static int
save_global(Picklerobject *self, PyObject *args, PyObject *name) {
PyObject *global_name = 0, *module = 0;
- char *name_str, *module_str;
+ char *name_str, *module_str;
int module_size, name_size, res = -1;
static char global = GLOBAL;
if (pid != Py_None) {
if (!self->bin) {
if (!PyString_Check(pid)) {
- PyErr_SetString(PicklingError,
+ PyErr_SetString(PicklingError,
"persistent id must be string");
goto finally;
}
if ((size = PyString_Size(pid)) < 0)
goto finally;
- if ((*self->write_func)(self,
+ if ((*self->write_func)(self,
PyString_AS_STRING((PyStringObject *)pid), size) < 0)
goto finally;
if ((*self->write_func)(self, "\n", 1) < 0)
goto finally;
-
+
res = 1;
goto finally;
}
res = 1;
}
- goto finally;
+ goto finally;
}
res = 0;
}
-static int
+static int
save_reduce(Picklerobject *self, PyObject *callable,
PyObject *tup, PyObject *state, PyObject *ob) {
static char reduce = REDUCE, build = BUILD;
return -1;
}
}
-
+
if (state) {
if (save(self, state, 0) < 0)
return -1;
case 'd':
if (type == &PyDict_Type) {
res = save_dict(self, args);
- goto finally;
+ goto finally;
}
break;
FREE_ARG_TUP(self);
}
if (! t) goto finally;
- }
+ }
else {
PyErr_Clear();
res = save_global(self, args, t);
goto finally;
}
-
+
if (!PyTuple_Check(t)) {
cPickle_ErrFormat(PicklingError, "Value returned by %s must "
"be a tuple", "O", __reduce__);
}
size = PyTuple_Size(t);
-
+
if ((size != 3) && (size != 2)) {
- cPickle_ErrFormat(PicklingError, "tuple returned by %s must "
+ cPickle_ErrFormat(PicklingError, "tuple returned by %s must "
"contain only two or three elements", "O", __reduce__);
goto finally;
}
-
+
callable = PyTuple_GET_ITEM(t, 0);
arg_tup = PyTuple_GET_ITEM(t, 1);
Py_XDECREF(py_ob_id);
Py_XDECREF(__reduce__);
Py_XDECREF(t);
-
+
return res;
}
/* set up an array to hold get/put status */
if ((lm=PyDict_Size(self->memo)) < 0) return NULL;
lm++;
- if (! (have_get=malloc((lm)*sizeof(char)))) return PyErr_NoMemory();
+ if (! (have_get=malloc((lm)*sizeof(char)))) return PyErr_NoMemory();
memset(have_get,0,lm);
/* Scan for gets. */
for (rsize=0, i=l; --i >= 0; ) {
k=data->data[i];
-
+
if (PyString_Check(k)) {
rsize += PyString_GET_SIZE(k);
}
PyErr_SetString(PicklingError,
"Invalid get data");
return NULL;
- }
+ }
if (have_get[ik]) { /* with matching get */
if (ik < 256) rsize += 2;
else rsize+=5;
PyErr_SetString(PicklingError,
"Invalid get data");
return NULL;
- }
+ }
have_get[ik]=1;
if (ik < 256) rsize += 2;
else rsize+=5;
PyDict_Clear(self->memo);
Pdata_clear(data,0);
}
-
+
free(have_get);
return r;
err:
Py_INCREF(file);
else
file=Pdata_New();
-
- UNLESS (self->file = file)
+
+ UNLESS (self->file = file)
goto err;
- UNLESS (self->memo = PyDict_New())
+ UNLESS (self->memo = PyDict_New())
goto err;
if (PyFile_Check(file)) {
}
}
- UNLESS (self->write_buf =
- (char *)malloc(WRITE_BUF_SIZE * sizeof(char))) {
+ UNLESS (self->write_buf =
+ (char *)malloc(WRITE_BUF_SIZE * sizeof(char))) {
PyErr_NoMemory();
goto err;
}
Py_XDECREF(self->inst_pers_func);
Py_XDECREF(self->dispatch_table);
- if (self->write_buf) {
+ if (self->write_buf) {
free(self->write_buf);
}
}
-int
+int
Pickler_setattr(Picklerobject *self, char *name, PyObject *value) {
if (! value) {
"attribute deletion is not supported");
return -1;
}
-
+
if (strcmp(name, "persistent_id") == 0) {
Py_XDECREF(self->pers_func);
self->pers_func = value;
if (fc) {
if (fc==Py_None) {
- PyErr_SetString(UnpicklingError,
+ PyErr_SetString(UnpicklingError,
"Global and instance pickles are not supported.");
return NULL;
}
char buf[256 + 37];
sprintf(buf, "Failed to import class %.128s from module %.128s",
PyString_AS_STRING((PyStringObject*)py_global_name),
- PyString_AS_STRING((PyStringObject*)py_module_name));
+ PyString_AS_STRING((PyStringObject*)py_module_name));
PyErr_SetString(PyExc_SystemError, buf);
return NULL;
}
return self->marks[--self->num_marks];
}
-
+
static int
load_none(Unpicklerobject *self) {
PDATA_APPEND(self->stack, Py_None, -1);
}
-static long
+static long
calc_binint(char *s, int x) {
unsigned char c;
int i;
return load_binintx(self, s, 2);
}
-
+
static int
load_long(Unpicklerobject *self) {
PyObject *l = 0;
return res;
}
-
+
static int
load_float(Unpicklerobject *self) {
PyObject *py_float = 0;
d = strtod(s, &endptr);
if (errno || (endptr[0] != '\n') || (endptr[1] != '\0')) {
- PyErr_SetString(PyExc_ValueError,
+ PyErr_SetString(PyExc_ValueError,
"could not convert string to float");
goto finally;
}
free(s);
return res;
-
+
insecure:
free(s);
PyErr_SetString(PyExc_ValueError,"insecure string pickle");
return -1;
-}
+}
static int
static int
load_short_binstring(Unpicklerobject *self) {
PyObject *py_string = 0;
- unsigned char l;
+ unsigned char l;
char *s;
if ((*self->read_func)(self, &s, 1) < 0)
PDATA_PUSH(self->stack, py_string, -1);
return 0;
-}
+}
static int
finally:
return res;
-}
+}
static int
if (PyClass_Check(cls)) {
int l;
-
+
if ((l=PyObject_Size(args)) < 0) goto err;
UNLESS (l) {
PyObject *__getinitargs__;
}
Py_DECREF(__getinitargs__);
}
-
+
if ((r=PyInstance_New(cls, args, NULL))) return r;
else goto err;
}
-
-
+
+
if ((has_key = cPickle_PyMapping_HasKey(safe_constructors, cls)) < 0)
goto err;
-
+
if (!has_key)
if (!(safe = PyObject_GetAttr(cls, __safe_for_unpickling___str)) ||
!PyObject_IsTrue(safe)) {
if (args==Py_None) {
/* Special case, call cls.__basicnew__() */
PyObject *basicnew;
-
+
UNLESS (basicnew=PyObject_GetAttr(cls, __basicnew___str)) return NULL;
r=PyObject_CallObject(basicnew, NULL);
Py_DECREF(basicnew);
}
return NULL;
}
-
+
static int
load_obj(Unpicklerobject *self) {
Py_DECREF(module_name);
if (! class) return -1;
-
+
if ((tup=Pdata_popTuple(self->stack, i))) {
obj = Instance_New(class, tup);
Py_DECREF(tup);
if (self->pers_func) {
if ((len = (*self->readline_func)(self, &s)) < 0) return -1;
if (len < 2) return bad_readline();
-
+
UNLESS (pid = PyString_FromStringAndSize(s, len - 1)) return -1;
if (PyList_Check(self->pers_func)) {
UNLESS ((len=self->stack->length) > 0) return stackUnderflow();
- /* Note that we split the (pickle.py) stack into two stacks,
+ /* Note that we split the (pickle.py) stack into two stacks,
an object stack and a mark stack. We have to be clever and
pop the right one. We do this by looking at the top of the
mark stack.
*/
- if ((self->num_marks > 0) &&
+ if ((self->num_marks > 0) &&
(self->marks[self->num_marks - 1] == len))
self->num_marks--;
- else {
+ else {
len--;
Py_DECREF(self->stack->data[len]);
self->stack->length=len;
key = (unsigned char)s[0];
UNLESS (py_key = PyInt_FromLong((long)key)) return -1;
-
+
value = PyDict_GetItem(self->memo, py_key);
if (! value) {
PyErr_SetObject(BadPickleGet, py_key);
key |= (long)c << 24;
UNLESS (py_key = PyInt_FromLong((long)key)) return -1;
-
+
value = PyDict_GetItem(self->memo, py_key);
if (! value) {
PyErr_SetObject(BadPickleGet, py_key);
}
-static int
+static int
do_append(Unpicklerobject *self, int x) {
PyObject *value = 0, *list = 0, *append_method = 0;
int len, i;
if (PyList_Check(list)) {
PyObject *slice;
int list_len;
-
+
slice=Pdata_popList(self->stack, x);
list_len = PyList_GET_SIZE(list);
i=PyList_SetSlice(list, list_len, list_len, slice);
UNLESS (append_method = PyObject_GetAttr(list, append_str))
return -1;
-
+
for (i = x; i < len; i++) {
PyObject *junk;
return 0;
}
-
+
static int
load_append(Unpicklerobject *self) {
return do_append(self, self->stack->length - 1);
static int
load_build(Unpicklerobject *self) {
- PyObject *value = 0, *inst = 0, *instdict = 0, *d_key = 0, *d_value = 0,
+ PyObject *value = 0, *inst = 0, *instdict = 0, *d_key = 0, *d_value = 0,
*junk = 0, *__setstate__ = 0;
int i, r = 0;
else r=-1;
Py_XDECREF(value);
-
+
return r;
}
/* Note that we split the (pickle.py) stack into two stacks, an
object stack and a mark stack. Here we push a mark onto the
- mark stack.
+ mark stack.
*/
if ((self->num_marks + 1) >= self->marks_size) {
Py_DECREF(arg_tup);
if (! ob) return -1;
-
+
PDATA_PUSH(self->stack, ob, -1);
return 0;
}
-
+
static PyObject *
load(Unpicklerobject *self) {
PyObject *err = 0, *val = 0;
if (load_appends(self) < 0)
break;
continue;
-
+
case BUILD:
if (load_build(self) < 0)
break;
continue;
-
+
case DUP:
if (load_dup(self) < 0)
break;
if (load_long_binget(self) < 0)
break;
continue;
-
+
case GET:
if (load_get(self) < 0)
break;
if (load_long_binput(self) < 0)
break;
continue;
-
+
case PUT:
if (load_put(self) < 0)
break;
break;
continue;
- default:
- cPickle_ErrFormat(UnpicklingError, "invalid load key, '%s'.",
+ default:
+ cPickle_ErrFormat(UnpicklingError, "invalid load key, '%s'.",
"c", s[0]);
return NULL;
}
if ((err = PyErr_Occurred())) {
if (err == PyExc_EOFError) {
PyErr_SetNone(PyExc_EOFError);
- }
+ }
return NULL;
}
- PDATA_POP(self->stack, val);
+ PDATA_POP(self->stack, val);
return val;
}
-
+
/* No-load functions to support noload, which is used to
find persistent references. */
if (load_appends(self) < 0)
break;
continue;
-
+
case BUILD:
if (noload_build(self) < 0)
break;
continue;
-
+
case DUP:
if (load_dup(self) < 0)
break;
if (load_long_binget(self) < 0)
break;
continue;
-
+
case GET:
if (load_get(self) < 0)
break;
if (load_long_binput(self) < 0)
break;
continue;
-
+
case PUT:
if (load_put(self) < 0)
break;
break;
continue;
- default:
- cPickle_ErrFormat(UnpicklingError, "invalid load key, '%s'.",
+ default:
+ cPickle_ErrFormat(UnpicklingError, "invalid load key, '%s'.",
"c", s[0]);
return NULL;
}
if ((err = PyErr_Occurred())) {
if (err == PyExc_EOFError) {
PyErr_SetNone(PyExc_EOFError);
- }
+ }
return NULL;
}
- PDATA_POP(self->stack, val);
+ PDATA_POP(self->stack, val);
return val;
}
-
+
static PyObject *
Unpickler_load(Unpicklerobject *self, PyObject *args) {
- UNLESS (PyArg_ParseTuple(args, ":load"))
+ UNLESS (PyArg_ParseTuple(args, ":load"))
return NULL;
return load(self);
static PyObject *
Unpickler_noload(Unpicklerobject *self, PyObject *args) {
- UNLESS (PyArg_ParseTuple(args, ":noload"))
+ UNLESS (PyArg_ParseTuple(args, ":noload"))
return NULL;
return noload(self);
self->safe_constructors = NULL;
self->find_class = NULL;
- UNLESS (self->memo = PyDict_New())
+ UNLESS (self->memo = PyDict_New())
goto err;
Py_INCREF(f);
static PyObject *
get_Unpickler(PyObject *self, PyObject *args) {
PyObject *file;
-
+
UNLESS (PyArg_ParseTuple(args, "O:Unpickler", &file))
return NULL;
return (PyObject *)newUnpicklerobject(file);
if (self->buf_size) {
free(self->buf);
}
-
+
PyObject_Del(self);
}
Py_XDECREF(file);
return res;
-}
-
+}
+
static PyObject *
cpm_load(PyObject *self, PyObject *args) {
UNLESS (file = PycStringIO->NewInput(ob))
goto finally;
-
+
UNLESS (unpickler = newUnpicklerobject(file))
goto finally;
}
-static char Unpicklertype__doc__[] =
+static char Unpicklertype__doc__[] =
"Objects that know how to unpickle";
static PyTypeObject Unpicklertype = {
return -1;
Py_DECREF(t);
-
- UNLESS (PicklingError = PyErr_NewException("cPickle.PicklingError",
+
+ UNLESS (PicklingError = PyErr_NewException("cPickle.PicklingError",
PickleError, NULL))
return -1;
Py_DECREF(t);
- UNLESS (UnpicklingError = PyErr_NewException("cPickle.UnpicklingError",
+ UNLESS (UnpicklingError = PyErr_NewException("cPickle.UnpicklingError",
PickleError, NULL))
return -1;
- if (PyDict_SetItemString(module_dict, "PickleError",
+ if (PyDict_SetItemString(module_dict, "PickleError",
PickleError) < 0)
return -1;
- if (PyDict_SetItemString(module_dict, "PicklingError",
+ if (PyDict_SetItemString(module_dict, "PicklingError",
PicklingError) < 0)
return -1;
return -1;
PycString_IMPORT;
-
+
return 0;
}
Unpicklertype.ob_type = &PyType_Type;
PdataType.ob_type = &PyType_Type;
- /* Initialize some pieces. We need to do this before module creation,
- so we're forced to use a temporary dictionary. :(
+ /* Initialize some pieces. We need to do this before module creation,
+ so we're forced to use a temporary dictionary. :(
*/
di=PyDict_New();
if (!di) return;