[3.6] bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (GH-3620). (#3773)

(cherry picked from commit 6db7033192)
This commit is contained in:
Serhiy Storchaka 2017-09-27 07:33:00 +03:00 committed by GitHub
parent a1c49f6f09
commit f0db2dfda7
4 changed files with 20 additions and 4 deletions

View file

@ -5254,6 +5254,10 @@ import_from(PyObject *v, PyObject *name)
if (pkgname == NULL) {
goto error;
}
if (!PyUnicode_Check(pkgname)) {
Py_CLEAR(pkgname);
goto error;
}
fullmodname = PyUnicode_FromFormat("%U.%U", pkgname, name);
Py_DECREF(pkgname);
if (fullmodname == NULL) {