Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

gh-129569: The function unicodedata.normalize() always returns built-in str #129570

Merged
Merged
Changes from 2 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
10 changes: 5 additions & 5 deletions Modules/unicodedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,34 +933,34 @@ unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form,
if (PyUnicode_GET_LENGTH(input) == 0) {
/* Special case empty input strings, since resizing
them later would cause internal errors. */
return Py_NewRef(input);
return PyUnicode_FromObject(input);
}

if (PyUnicode_CompareWithASCIIString(form, "NFC") == 0) {
if (is_normalized_quickcheck(self, input,
true, false, true) == YES) {
return Py_NewRef(input);
return PyUnicode_FromObject(input);
}
return nfc_nfkc(self, input, 0);
}
if (PyUnicode_CompareWithASCIIString(form, "NFKC") == 0) {
if (is_normalized_quickcheck(self, input,
true, true, true) == YES) {
return Py_NewRef(input);
return PyUnicode_FromObject(input);
}
return nfc_nfkc(self, input, 1);
}
if (PyUnicode_CompareWithASCIIString(form, "NFD") == 0) {
if (is_normalized_quickcheck(self, input,
false, false, true) == YES) {
return Py_NewRef(input);
return PyUnicode_FromObject(input);
}
return nfd_nfkd(self, input, 0);
}
if (PyUnicode_CompareWithASCIIString(form, "NFKD") == 0) {
if (is_normalized_quickcheck(self, input,
false, true, true) == YES) {
return Py_NewRef(input);
return PyUnicode_FromObject(input);
}
return nfd_nfkd(self, input, 1);
}
Expand Down
Loading