Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-98354: Add unicode check for 'name' attribute in _imp_create_builtin #98412

Merged
8 changes: 8 additions & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
chgnrdv marked this conversation as resolved.
Show resolved Hide resolved
}

PyObject *mod = create_builtin(tstate, name, spec);
Py_DECREF(name);
return mod;
Expand Down