[Python-checkins] r56185 - python/branches/cpy_merge/Modules/_picklemodule.c

alexandre.vassalotti python-checkins at python.org
Sat Jul 7 20:36:09 CEST 2007


Author: alexandre.vassalotti
Date: Sat Jul  7 20:36:09 2007
New Revision: 56185

Modified:
   python/branches/cpy_merge/Modules/_picklemodule.c
Log:
Remove dependency on cStringIO.
Remove the dumps and loads methods.


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  7 20:36:09 2007
@@ -1,5 +1,4 @@
 #include "Python.h"
-#include "cStringIO.h"
 #include "structmember.h"
 
 PyDoc_STRVAR(pickle_module_documentation,
@@ -443,20 +442,6 @@
 }
 
 static int
-write_cStringIO(Picklerobject * self, const char *s, Py_ssize_t n)
-{
-    if (s == NULL) {
-        return 0;
-    }
-
-    if (PycStringIO->cwrite((PyObject *) self->file, s, n) != n) {
-        return -1;
-    }
-
-    return (int) n;
-}
-
-static int
 write_none(Picklerobject * self, const char *s, Py_ssize_t n)
 {
     if (s == NULL)
@@ -602,39 +587,6 @@
     }
 }
 
-
-static Py_ssize_t
-read_cStringIO(Unpicklerobject * self, char **s, Py_ssize_t n)
-{
-    char *ptr;
-
-    if (PycStringIO->cread((PyObject *) self->file, &ptr, n) != n) {
-        PyErr_SetNone(PyExc_EOFError);
-        return -1;
-    }
-
-    *s = ptr;
-
-    return n;
-}
-
-
-static Py_ssize_t
-readline_cStringIO(Unpicklerobject * self, char **s)
-{
-    Py_ssize_t n;
-    char *ptr;
-
-    if ((n = PycStringIO->creadline((PyObject *) self->file, &ptr)) < 0) {
-        return -1;
-    }
-
-    *s = ptr;
-
-    return n;
-}
-
-
 static Py_ssize_t
 read_other(Unpicklerobject * self, char **s, Py_ssize_t n)
 {
@@ -2678,9 +2630,6 @@
         }
         self->write_func = write_file;
     }
-    else if (PycStringIO_OutputCheck(file)) {
-        self->write_func = write_cStringIO;
-    }
     else if (file == Py_None) {
         self->write_func = write_none;
     }
@@ -5091,11 +5040,6 @@
         self->read_func = read_file;
         self->readline_func = readline_file;
     }
-    else if (PycStringIO_InputCheck(f)) {
-        self->fp = NULL;
-        self->read_func = read_cStringIO;
-        self->readline_func = readline_cStringIO;
-    }
     else {
 
         self->fp = NULL;
@@ -5296,39 +5240,6 @@
     return res;
 }
 
-
-/* dumps(obj, protocol=0). */
-static PyObject *
-cpm_dumps(PyObject * self, PyObject * args, PyObject * kwds)
-{
-    static char *kwlist[] = { "obj", "protocol", NULL };
-    PyObject *ob, *file = 0, *res = NULL;
-    Picklerobject *pickler = 0;
-    int proto = 0;
-
-    if (!(PyArg_ParseTupleAndKeywords(args, kwds, "O|i:dumps", kwlist,
-                                      &ob, &proto)))
-        goto finally;
-
-    if (!(file = PycStringIO->NewOutput(128)))
-        goto finally;
-
-    if (!(pickler = newPicklerobject(file, proto)))
-        goto finally;
-
-    if (dump(pickler, ob) < 0)
-        goto finally;
-
-    res = PycStringIO->cgetvalue(file);
-
-  finally:
-    Py_XDECREF(pickler);
-    Py_XDECREF(file);
-
-    return res;
-}
-
-
 /* load(fileobj). */
 static PyObject *
 cpm_load(PyObject * self, PyObject * ob)
@@ -5347,33 +5258,6 @@
     return res;
 }
 
-
-/* loads(string) */
-static PyObject *
-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 (!(file = PycStringIO->NewInput(ob)))
-        goto finally;
-
-    if (!(unpickler = newUnpicklerobject(file)))
-        goto finally;
-
-    res = load(unpickler);
-
-  finally:
-    Py_XDECREF(file);
-    Py_XDECREF(unpickler);
-
-    return res;
-}
-
-
 PyDoc_STRVAR(Unpicklertype__doc__, "Objects that know how to unpickle");
 
 static PyTypeObject Unpicklertype = {
@@ -5411,19 +5295,9 @@
                "See the Pickler docstring for the meaning of optional argument proto.")
      },
 
-    {"dumps", (PyCFunction) cpm_dumps, METH_VARARGS | METH_KEYWORDS,
-     PyDoc_STR("dumps(obj, protocol=0) -- "
-               "Return a string containing an object in pickle format.\n"
-               "\n"
-               "See the Pickler docstring for the meaning of optional argument proto.")
-     },
-
     {"load", (PyCFunction) cpm_load, METH_O,
      PyDoc_STR("load(file) -- Load a pickle from the given file")},
 
-    {"loads", (PyCFunction) cpm_loads, METH_VARARGS,
-     PyDoc_STR("loads(string) -- Load a pickle from the given string")},
-
     {"Pickler", (PyCFunction) get_Pickler, METH_VARARGS | METH_KEYWORDS,
      PyDoc_STR("Pickler(file, protocol=0) -- Create a pickler.\n"
                "\n"
@@ -5586,8 +5460,6 @@
     if (PyDict_SetItemString(module_dict, "BadPickleGet", BadPickleGet) < 0)
         return -1;
 
-    PycString_IMPORT;
-
     return 0;
 }
 


More information about the Python-checkins mailing list