mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
save_global(): Trying to resolve module.name can fail for two
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.
This commit is contained in:
parent
97e5ff555e
commit
b9ce7cd8b8
1 changed files with 5 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue