[Python-checkins] r56378 - python/branches/cpy_merge/Modules/_picklemodule.c
alexandre.vassalotti
python-checkins at python.org
Sat Jul 14 21:23:08 CEST 2007
Author: alexandre.vassalotti
Date: Sat Jul 14 21:23:07 2007
New Revision: 56378
Modified:
python/branches/cpy_merge/Modules/_picklemodule.c
Log:
Remove the no-load functions.
Modified: python/branches/cpy_merge/Modules/_picklemodule.c
==============================================================================
--- python/branches/cpy_merge/Modules/_picklemodule.c (original)
+++ python/branches/cpy_merge/Modules/_picklemodule.c Sat Jul 14 21:23:07 2007
@@ -2382,10 +2382,10 @@
static struct PyMethodDef Pickler_methods[] = {
{"dump", (PyCFunction) Pickler_dump, METH_VARARGS,
- PyDoc_STR("dump(object) -- "
+ PyDoc_STR("dump(object) -> None.\n\n"
"Write an object in pickle format to the object's pickle stream")},
{"clear_memo", (PyCFunction) Pickle_clear_memo, METH_NOARGS,
- PyDoc_STR("clear_memo() -- Clear the picklers memo")},
+ PyDoc_STR("clear_memo() -> None. Clear the picklers memo.")},
{NULL, NULL} /* sentinel */
};
@@ -4387,428 +4387,16 @@
}
-/* No-load functions to support noload, which is used to
- find persistent references. */
-
-static int
-noload_obj(UnpicklerObject * self)
-{
- int i;
-
- if ((i = marker(self)) < 0)
- return -1;
- return Pdata_clear(self->stack, i + 1);
-}
-
-
-static int
-noload_inst(UnpicklerObject * self)
-{
- int i;
- char *s;
-
- if ((i = marker(self)) < 0)
- return -1;
- Pdata_clear(self->stack, i);
- if (self->readline_func(self, &s) < 0)
- return -1;
- if (self->readline_func(self, &s) < 0)
- return -1;
- PDATA_APPEND(self->stack, Py_None, -1);
- return 0;
-}
-
-static int
-noload_newobj(UnpicklerObject * self)
-{
- PyObject *obj;
-
- PDATA_POP(self->stack, obj); /* pop argtuple */
- if (obj == NULL)
- return -1;
- Py_DECREF(obj);
-
- PDATA_POP(self->stack, obj); /* pop cls */
- if (obj == NULL)
- return -1;
- Py_DECREF(obj);
-
- PDATA_APPEND(self->stack, Py_None, -1);
- return 0;
-}
-
-static int
-noload_global(UnpicklerObject *self)
-{
- char *s;
-
- if (self->readline_func(self, &s) < 0)
- return -1;
- if (self->readline_func(self, &s) < 0)
- return -1;
- PDATA_APPEND(self->stack, Py_None, -1);
- return 0;
-}
-
-static int
-noload_reduce(UnpicklerObject *self)
-{
-
- if (self->stack->length < 2)
- return stackUnderflow();
- Pdata_clear(self->stack, self->stack->length - 2);
- PDATA_APPEND(self->stack, Py_None, -1);
- return 0;
-}
-
-static int
-noload_build(UnpicklerObject *self)
-{
-
- if (self->stack->length < 1)
- return stackUnderflow();
- Pdata_clear(self->stack, self->stack->length - 1);
- return 0;
-}
-
-static int
-noload_extension(UnpicklerObject *self, int nbytes)
-{
- char *codebytes;
-
- assert(nbytes == 1 || nbytes == 2 || nbytes == 4);
- if (self->read_func(self, &codebytes, nbytes) < 0)
- return -1;
- PDATA_APPEND(self->stack, Py_None, -1);
- return 0;
-}
-
-
static PyObject *
-noload(UnpicklerObject *self)
-{
- PyObject *err = 0, *val = 0;
- char *s;
-
- self->num_marks = 0;
- Pdata_clear(self->stack, 0);
-
- while (1) {
- if (self->read_func(self, &s, 1) < 0)
- break;
-
- switch (s[0]) {
- case NONE:
- if (load_none(self) < 0)
- break;
- continue;
-
- case BININT:
- if (load_binint(self) < 0)
- break;
- continue;
-
- case BININT1:
- if (load_binint1(self) < 0)
- break;
- continue;
-
- case BININT2:
- if (load_binint2(self) < 0)
- break;
- continue;
-
- case INT:
- if (load_int(self) < 0)
- break;
- continue;
-
- case LONG:
- if (load_long(self) < 0)
- break;
- continue;
-
- case LONG1:
- if (load_counted_long(self, 1) < 0)
- break;
- continue;
-
- case LONG4:
- if (load_counted_long(self, 4) < 0)
- break;
- continue;
-
- case FLOAT:
- if (load_float(self) < 0)
- break;
- continue;
-
- case BINFLOAT:
- if (load_binfloat(self) < 0)
- break;
- continue;
-
- case BINSTRING:
- if (load_binstring(self) < 0)
- break;
- continue;
-
- case SHORT_BINSTRING:
- if (load_short_binstring(self) < 0)
- break;
- continue;
-
- case STRING:
- if (load_string(self) < 0)
- break;
- continue;
-
-#ifdef Py_USING_UNICODE
- case UNICODE:
- if (load_unicode(self) < 0)
- break;
- continue;
-
- case BINUNICODE:
- if (load_binunicode(self) < 0)
- break;
- continue;
-#endif
-
- case EMPTY_TUPLE:
- if (load_counted_tuple(self, 0) < 0)
- break;
- continue;
-
- case TUPLE1:
- if (load_counted_tuple(self, 1) < 0)
- break;
- continue;
-
- case TUPLE2:
- if (load_counted_tuple(self, 2) < 0)
- break;
- continue;
-
- case TUPLE3:
- if (load_counted_tuple(self, 3) < 0)
- break;
- continue;
-
- case TUPLE:
- if (load_tuple(self) < 0)
- break;
- continue;
-
- case EMPTY_LIST:
- if (load_empty_list(self) < 0)
- break;
- continue;
-
- case LIST:
- if (load_list(self) < 0)
- break;
- continue;
-
- case EMPTY_DICT:
- if (load_empty_dict(self) < 0)
- break;
- continue;
-
- case DICT:
- if (load_dict(self) < 0)
- break;
- continue;
-
- case OBJ:
- if (noload_obj(self) < 0)
- break;
- continue;
-
- case INST:
- if (noload_inst(self) < 0)
- break;
- continue;
-
- case NEWOBJ:
- if (noload_newobj(self) < 0)
- break;
- continue;
-
- case GLOBAL:
- if (noload_global(self) < 0)
- break;
- continue;
-
- case APPEND:
- if (load_append(self) < 0)
- break;
- continue;
-
- case APPENDS:
- if (load_appends(self) < 0)
- break;
- continue;
-
- case BUILD:
- if (noload_build(self) < 0)
- break;
- continue;
-
- case DUP:
- if (load_dup(self) < 0)
- break;
- continue;
-
- case BINGET:
- if (load_binget(self) < 0)
- break;
- continue;
-
- case LONG_BINGET:
- if (load_long_binget(self) < 0)
- break;
- continue;
-
- case GET:
- if (load_get(self) < 0)
- break;
- continue;
-
- case EXT1:
- if (noload_extension(self, 1) < 0)
- break;
- continue;
-
- case EXT2:
- if (noload_extension(self, 2) < 0)
- break;
- continue;
-
- case EXT4:
- if (noload_extension(self, 4) < 0)
- break;
- continue;
-
- case MARK:
- if (load_mark(self) < 0)
- break;
- continue;
-
- case BINPUT:
- if (load_binput(self) < 0)
- break;
- continue;
-
- case LONG_BINPUT:
- if (load_long_binput(self) < 0)
- break;
- continue;
-
- case PUT:
- if (load_put(self) < 0)
- break;
- continue;
-
- case POP:
- if (load_pop(self) < 0)
- break;
- continue;
-
- case POP_MARK:
- if (load_pop_mark(self) < 0)
- break;
- continue;
-
- case SETITEM:
- if (load_setitem(self) < 0)
- break;
- continue;
-
- case SETITEMS:
- if (load_setitems(self) < 0)
- break;
- continue;
-
- case STOP:
- break;
-
- case PERSID:
- if (load_persid(self) < 0)
- break;
- continue;
-
- case BINPERSID:
- if (load_binpersid(self) < 0)
- break;
- continue;
-
- case REDUCE:
- if (noload_reduce(self) < 0)
- break;
- continue;
-
- case PROTO:
- if (load_proto(self) < 0)
- break;
- continue;
-
- case NEWTRUE:
- if (load_bool(self, Py_True) < 0)
- break;
- continue;
-
- case NEWFALSE:
- if (load_bool(self, Py_False) < 0)
- break;
- continue;
- default:
- pickle_ErrFormat(UnpicklingError,
- "invalid load key, '%s'.", "c", s[0]);
- return NULL;
- }
-
- break;
- }
-
- if ((err = PyErr_Occurred())) {
- if (err == PyExc_EOFError) {
- PyErr_SetNone(PyExc_EOFError);
- }
- return NULL;
- }
-
- PDATA_POP(self->stack, val);
- return val;
-}
-
-
-static PyObject *
-Unpickler_load(UnpicklerObject * self, PyObject * unused)
+Unpickler_load(UnpicklerObject *self)
{
return load(self);
}
-static PyObject *
-Unpickler_noload(UnpicklerObject *self, PyObject *unused)
-{
- return noload(self);
-}
-
static struct PyMethodDef Unpickler_methods[] = {
- {"load", (PyCFunction) Unpickler_load, METH_NOARGS,
- PyDoc_STR("load() -- Load a pickle")
- },
- {"noload", (PyCFunction) Unpickler_noload, METH_NOARGS,
- PyDoc_STR
- ("noload() -- not load a pickle, but go through most of the motions\n"
- "\n"
- "This function can be used to read past a pickle without instantiating\n"
- "any objects or importing any modules. It can also be used to find all\n"
- "persistent references without instantiating any objects or importing\n"
- "any modules.\n")
- },
+ {"load", (PyCFunction)Unpickler_load, METH_NOARGS,
+ PyDoc_STR("load() -> None. Load a pickle")},
{NULL, NULL} /* sentinel */
};
More information about the Python-checkins
mailing list