From f1b35194f497f53547d3616146282b27c6a5f2ef Mon Sep 17 00:00:00 2001 From: "zainnadeem(RedOpsCell)" Date: Thu, 25 Jun 2026 12:25:00 +0500 Subject: [PATCH] gh-151763: Avoid unicode singleton check on NULL data --- Objects/unicodeobject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 3c689761de9b199..3e7a54afcd98292 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1720,6 +1720,9 @@ unicode_is_singleton(PyObject *unicode) PyASCIIObject *ascii = _PyASCIIObject_CAST(unicode); if (ascii->length == 1) { + if (!PyUnicode_IS_COMPACT(unicode) && _PyUnicode_DATA_ANY(unicode) == NULL) { + return 0; + } Py_UCS4 ch = PyUnicode_READ_CHAR(unicode, 0); if (ch < 256 && LATIN1(ch) == unicode) { return 1;