From 99a51d4e5b154a7b8d971090fecc1e34769a3ca1 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 19 Sep 2017 05:51:19 -0700 Subject: [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 9974e1bcf3d0cec9b38b39b39b7ec8a1ebd9ef54) --- Python/importdl.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Python/importdl.c') diff --git a/Python/importdl.c b/Python/importdl.c index f56fa94cc4..326b26fd06 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -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) { -- cgit v1.2.1