Special case normalization of empty strings. Fixes #924361.
Backported to 2.3.
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index 311db29..ba218a3 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -515,6 +515,13 @@
&form, &PyUnicode_Type, &input))
return NULL;
+ if (PyUnicode_GetSize(input) == 0) {
+ /* Special case empty input strings, since resizing
+ them later would cause internal errors. */
+ Py_INCREF(input);
+ return input;
+ }
+
if (strcmp(form, "NFC") == 0)
return nfc_nfkc(input, 0);
if (strcmp(form, "NFKC") == 0)