Commit a06f83ef authored by Jim Fulton's avatar Jim Fulton

Incorporated bug fixes from Jeremy Hylton.

parent 31b04ffd
/*
$Id: cPickle.c,v 1.56 1998/08/12 12:07:42 jim Exp $
$Id: cPickle.c,v 1.57 1998/08/12 12:13:28 jim Exp $
Copyright
......@@ -55,7 +55,7 @@
static char cPickle_module_documentation[] =
"C implementation and optimization of the Python pickle module\n"
"\n"
"$Id: cPickle.c,v 1.56 1998/08/12 12:07:42 jim Exp $\n"
"$Id: cPickle.c,v 1.57 1998/08/12 12:13:28 jim Exp $\n"
;
#include "Python.h"
......@@ -1973,22 +1973,32 @@ static PyTypeObject Picklertype = {
static PyObject *
find_class(PyObject *py_module_name, PyObject *py_global_name) {
PyObject *global = 0, *module;
UNLESS(module=PySys_GetObject("modules")) return NULL;
if(module=PyDict_GetItem(module, py_module_name)) {
global=PyObject_GetAttr(module, py_global_name);
}
else {
PyErr_Clear();
UNLESS(module=PyImport_Import(py_module_name)) return NULL;
global=PyObject_GetAttr(module, py_global_name);
module = PySys_GetObject("modules");
if (module == NULL)
return NULL;
module = PyDict_GetItem(module, py_module_name);
if (module == NULL) {
module = PyImport_Import(py_module_name);
if (!module)
return NULL;
global = PyObject_GetAttr(module, py_global_name);
Py_DECREF(module);
}
else
global = PyObject_GetAttr(module, py_global_name);
if (global == NULL) {
char buf[256 + 37];
sprintf(buf, "Failed to import class %.128s from moduile %.128s",
PyString_AS_STRING((PyStringObject*)py_global_name),
PyString_AS_STRING((PyStringObject*)py_module_name));
PyErr_SetString(PyExc_SystemError, buf);
return NULL;
}
return global;
}
static int
marker(Unpicklerobject *self) {
if (self->num_marks < 1) {
......@@ -4156,7 +4166,7 @@ cpm_loads(PyObject *self, PyObject *args) {
PyObject *ob, *file = 0, *res = NULL;
Unpicklerobject *unpickler = 0;
UNLESS(PyArg_ParseTuple(args, "O", &ob))
UNLESS(PyArg_ParseTuple(args, "S", &ob))
goto finally;
UNLESS(file = PycStringIO->NewInput(ob))
......@@ -4325,7 +4335,7 @@ init_stuff(PyObject *module, PyObject *module_dict) {
void
initcPickle() {
PyObject *m, *d, *v;
char *rev="$Revision: 1.56 $";
char *rev="$Revision: 1.57 $";
PyObject *format_version;
PyObject *compatible_formats;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment