]> granicus.if.org Git - python/commitdiff
save_global(): Trying to resolve module.name can fail for two
authorTim Peters <tim.peters@gmail.com>
Tue, 18 Feb 2003 20:50:45 +0000 (20:50 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 18 Feb 2003 20:50:45 +0000 (20:50 +0000)
reasons:  importing module can fail, or the attribute lookup
module.name can fail.  We were giving the same error msg for
both cases, making it needlessly hard to guess what went wrong.
These cases give different error msgs now.

Modules/cPickle.c

index ad087a9f25759298edf9e975fb48f94d40e3253c..0d78e49f8f3b47b377eab932d3051f14af85767b 100644 (file)
@@ -2021,14 +2021,16 @@ save_global(Picklerobject *self, PyObject *args, PyObject *name)
        mod = PyImport_ImportModule(module_str);
        if (mod == NULL) {
                cPickle_ErrFormat(PicklingError,
-                                 "Can't pickle %s: it's not found as %s.%s",
-                                 "OSS", args, module, global_name);
+                                 "Can't pickle %s: import of module %s "
+                                 "failed",
+                                 "OS", args, module);
                goto finally;
        }
        klass = PyObject_GetAttrString(mod, name_str);
        if (klass == NULL) {
                cPickle_ErrFormat(PicklingError,
-                                 "Can't pickle %s: it's not found as %s.%s",
+                                 "Can't pickle %s: attribute lookup %s.%s "
+                                 "failed",
                                  "OSS", args, module, global_name);
                goto finally;
        }