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

This commit is contained in:
Oren Milman 2017-09-19 14:39:47 +03:00 committed by Serhiy Storchaka
parent 6db7033192
commit 9974e1bcf3
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) {