Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add unicode check for 'name' attribute in _imp_create_builtin
_imp_create_builtin crashes if 'name' attribute of 'spec' argument is not a 'str' instance. This commit adds appropriate check.
  • Loading branch information
chgnrdv committed Oct 18, 2022
commit 866bf6772e51c1a6c3ec948cdac18bc4b2d65e8a
7 changes: 7 additions & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,13 @@ _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);
return NULL;
}

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