static int
save_global(Picklerobject *self, PyObject *args, PyObject *name) {
- PyObject *global_name = 0, *module = 0, *mod = 0, *moddict = 0, *klass = 0;
+ PyObject *global_name = 0, *module = 0, *mod = 0, *klass = 0;
char *name_str, *module_str;
int module_size, name_size, res = -1;
"OSS", args, module, global_name);
goto finally;
}
- moddict = PyModule_GetDict(mod); /* borrowed ref */
- klass = PyDict_GetItemString(moddict, name_str); /* borrowed ref */
+ klass = PyObject_GetAttrString(mod, name_str);
if (klass == NULL) {
cPickle_ErrFormat(PicklingError,
"Can't pickle %s: it's not found as %s.%s",
goto finally;
}
if (klass != args) {
+ Py_DECREF(klass);
cPickle_ErrFormat(PicklingError,
"Can't pickle %s: it's not the same object as %s.%s",
"OSS", args, module, global_name);
goto finally;
}
+ Py_DECREF(klass);
if ((*self->write_func)(self, &global, 1) < 0)
goto finally;