diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 3c689761de9b19..3e7a54afcd9829 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;