diff options
author | Brett Cannon <brett@python.org> | 2015-08-14 18:09:56 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2015-08-14 18:09:56 (GMT) |
commit | d8683762884e82c81b8c5c0db8aa4045c3fbb284 (patch) | |
tree | 3ea76e5575d524e0898351b388865a28ff4fd227 /Python | |
parent | 28c995d03b6e2f5a77c42a97e95368767846f14f (diff) | |
parent | 7c97a05618733b93f0a6e80ad5b672c2f966f448 (diff) | |
download | cpython-d8683762884e82c81b8c5c0db8aa4045c3fbb284.zip cpython-d8683762884e82c81b8c5c0db8aa4045c3fbb284.tar.gz cpython-d8683762884e82c81b8c5c0db8aa4045c3fbb284.tar.bz2 |
Merge from 3.5 for issue #24492
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index ac52ad9..8d2cdc2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -5085,19 +5085,24 @@ import_from(PyObject *v, PyObject *name) sys.modules. */ PyErr_Clear(); pkgname = _PyObject_GetAttrId(v, &PyId___name__); - if (pkgname == NULL) - return NULL; + if (pkgname == NULL) { + goto error; + } fullmodname = PyUnicode_FromFormat("%U.%U", pkgname, name); Py_DECREF(pkgname); - if (fullmodname == NULL) + if (fullmodname == NULL) { return NULL; + } x = PyDict_GetItem(PyImport_GetModuleDict(), fullmodname); - if (x == NULL) - PyErr_Format(PyExc_ImportError, "cannot import name %R", name); - else - Py_INCREF(x); Py_DECREF(fullmodname); + if (x == NULL) { + goto error; + } + Py_INCREF(x); return x; + error: + PyErr_Format(PyExc_ImportError, "cannot import name %R", name); + return NULL; } static int |