[3.13] gh-150633: Properly handle null characters in the name when importing frozen modules (GH-150634) (GH-151102)

(cherry picked from commit 54de5475cd)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
This commit is contained in:
Miss Islington (bot) 2026-06-08 20:55:43 +02:00 committed by GitHub
parent 947aa707c1
commit 4834b45ee7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 1 deletions

View file

@ -2986,7 +2986,7 @@ find_frozen(PyObject *nameobj, struct frozen_info *info)
if (nameobj == NULL || nameobj == Py_None) {
return FROZEN_BAD_NAME;
}
const char *name = PyUnicode_AsUTF8(nameobj);
const char *name = _PyUnicode_AsUTF8NoNUL(nameobj);
if (name == NULL) {
// Note that this function previously used
// _PyUnicode_EqualToASCIIString(). We clear the error here