summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorchgnrdv <52372310+chgnrdv@users.noreply.github.com>2022-10-20 00:25:10 (GMT)
committerGitHub <noreply@github.com>2022-10-20 00:25:10 (GMT)
commit1f369ad07ff44b1fd6db75b33298e20ad604efc8 (patch)
tree42ac5acd81c4097c33a7073b9c4ccfaf2997c900 /Python
parenta8fe4bbd6b78517f640e25697338b9448c4675c1 (diff)
downloadcpython-1f369ad07ff44b1fd6db75b33298e20ad604efc8.zip
cpython-1f369ad07ff44b1fd6db75b33298e20ad604efc8.tar.gz
cpython-1f369ad07ff44b1fd6db75b33298e20ad604efc8.tar.bz2
gh-98354: Add unicode check for 'name' attribute in _imp_create_builtin (GH-98412)
Fixes #98354
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/import.c b/Python/import.c
index 698ef37..9d35d26 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;