From 1f369ad07ff44b1fd6db75b33298e20ad604efc8 Mon Sep 17 00:00:00 2001 From: chgnrdv <52372310+chgnrdv@users.noreply.github.com> Date: Thu, 20 Oct 2022 03:25:10 +0300 Subject: gh-98354: Add unicode check for 'name' attribute in _imp_create_builtin (GH-98412) Fixes #98354 --- Python/import.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index 698ef37ce0..9d35d26177 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1021,6 +1021,14 @@ _imp_create_builtin(PyObject *module, PyObject *spec) return NULL; } + if (!PyUnicode_Check(name)) { + PyErr_Format(PyExc_TypeError, + "name must be string, not %.200s", + Py_TYPE(name)->tp_name); + Py_DECREF(name); + return NULL; + } + PyObject *mod = create_builtin(tstate, name, spec); Py_DECREF(name); return mod; -- cgit v1.2.1