Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Raise :exc:`TypeError` instead of crashing when empty string is used as a
name in ``importlib._imp.create_builtin``.
7 changes: 7 additions & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -4420,6 +4420,13 @@ _imp_create_builtin(PyObject *module, PyObject *spec)
return NULL;
}

if (PyUnicode_GetLength(name) == 0) {
PyErr_Format(PyExc_TypeError,
"name must not be empty");
Py_DECREF(name);
return NULL;
}

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