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 Copyright
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
static char cPickle_module_documentation[] = static char cPickle_module_documentation[] =
"C implementation and optimization of the Python pickle module\n" "C implementation and optimization of the Python pickle module\n"
"\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" #include "Python.h"
...@@ -1974,21 +1974,31 @@ static PyObject * ...@@ -1974,21 +1974,31 @@ static PyObject *
find_class(PyObject *py_module_name, PyObject *py_global_name) { find_class(PyObject *py_module_name, PyObject *py_global_name) {
PyObject *global = 0, *module; PyObject *global = 0, *module;
UNLESS(module=PySys_GetObject("modules")) return NULL; module = PySys_GetObject("modules");
if(module=PyDict_GetItem(module, py_module_name)) { if (module == NULL)
global=PyObject_GetAttr(module, py_global_name); return NULL;
}
else { module = PyDict_GetItem(module, py_module_name);
PyErr_Clear(); if (module == NULL) {
UNLESS(module=PyImport_Import(py_module_name)) return NULL; module = PyImport_Import(py_module_name);
global=PyObject_GetAttr(module, py_global_name); if (!module)
return NULL;
global = PyObject_GetAttr(module, py_global_name);
Py_DECREF(module); 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; return global;
} }
static int static int
marker(Unpicklerobject *self) { marker(Unpicklerobject *self) {
if (self->num_marks < 1) { if (self->num_marks < 1) {
...@@ -4156,7 +4166,7 @@ cpm_loads(PyObject *self, PyObject *args) { ...@@ -4156,7 +4166,7 @@ cpm_loads(PyObject *self, PyObject *args) {
PyObject *ob, *file = 0, *res = NULL; PyObject *ob, *file = 0, *res = NULL;
Unpicklerobject *unpickler = 0; Unpicklerobject *unpickler = 0;
UNLESS(PyArg_ParseTuple(args, "O", &ob)) UNLESS(PyArg_ParseTuple(args, "S", &ob))
goto finally; goto finally;
UNLESS(file = PycStringIO->NewInput(ob)) UNLESS(file = PycStringIO->NewInput(ob))
...@@ -4325,7 +4335,7 @@ init_stuff(PyObject *module, PyObject *module_dict) { ...@@ -4325,7 +4335,7 @@ init_stuff(PyObject *module, PyObject *module_dict) {
void void
initcPickle() { initcPickle() {
PyObject *m, *d, *v; PyObject *m, *d, *v;
char *rev="$Revision: 1.56 $"; char *rev="$Revision: 1.57 $";
PyObject *format_version; PyObject *format_version;
PyObject *compatible_formats; 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