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

This commit is contained in:
Oren Milman 2017-09-19 14:23:01 +03:00 committed by Serhiy Storchaka
parent 453408a505
commit 6db7033192
4 changed files with 20 additions and 4 deletions

View file

@ -4930,6 +4930,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);
if (fullmodname == NULL) {
Py_DECREF(pkgname);