[3.6] bpo-31315: Fix an assertion failure in imp.create_dynamic(), when spec.name is not a string. (GH-3257) (#3653)

(cherry picked from commit 9974e1bcf3)
This commit is contained in:
Miss Islington (bot) 2017-09-19 05:51:19 -07:00 committed by Serhiy Storchaka
parent 113bc6f57b
commit 99a51d4e5b
3 changed files with 18 additions and 0 deletions

View file

@ -103,6 +103,11 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp)
if (name_unicode == NULL) {
return NULL;
}
if (!PyUnicode_Check(name_unicode)) {
PyErr_SetString(PyExc_TypeError,
"spec.name must be a string");
goto error;
}
name = get_encoded_name(name_unicode, &hook_prefix);
if (name == NULL) {