Skip to content

Commit 2bf5f64

Browse files
authored
Remove usage of _Py_IDENTIFIER from unicodedata module. (GH-91532)
1 parent f1e989b commit 2bf5f64

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

Modules/unicodedata.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#ifndef Py_BUILD_CORE_BUILTIN
1616
# define Py_BUILD_CORE_MODULE 1
1717
#endif
18-
#define NEEDS_PY_IDENTIFIER
1918

2019
#define PY_SSIZE_T_CLEAN
2120

@@ -25,11 +24,6 @@
2524

2625
#include <stdbool.h>
2726

28-
_Py_IDENTIFIER(NFC);
29-
_Py_IDENTIFIER(NFD);
30-
_Py_IDENTIFIER(NFKC);
31-
_Py_IDENTIFIER(NFKD);
32-
3327
/*[clinic input]
3428
module unicodedata
3529
class unicodedata.UCD 'PreviousDBVersion *' '<not used>'
@@ -890,17 +884,17 @@ unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form,
890884
PyObject *cmp;
891885
int match = 0;
892886

893-
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFC)) {
887+
if (PyUnicode_CompareWithASCIIString(form, "NFC") == 0) {
894888
nfc = true;
895889
}
896-
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKC)) {
890+
else if (PyUnicode_CompareWithASCIIString(form, "NFKC") == 0) {
897891
nfc = true;
898892
k = true;
899893
}
900-
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFD)) {
894+
else if (PyUnicode_CompareWithASCIIString(form, "NFD") == 0) {
901895
/* matches default values for `nfc` and `k` */
902896
}
903-
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKD)) {
897+
else if (PyUnicode_CompareWithASCIIString(form, "NFKD") == 0) {
904898
k = true;
905899
}
906900
else {
@@ -953,31 +947,31 @@ unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form,
953947
return input;
954948
}
955949

956-
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFC)) {
950+
if (PyUnicode_CompareWithASCIIString(form, "NFC") == 0) {
957951
if (is_normalized_quickcheck(self, input,
958952
true, false, true) == YES) {
959953
Py_INCREF(input);
960954
return input;
961955
}
962956
return nfc_nfkc(self, input, 0);
963957
}
964-
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKC)) {
958+
if (PyUnicode_CompareWithASCIIString(form, "NFKC") == 0) {
965959
if (is_normalized_quickcheck(self, input,
966960
true, true, true) == YES) {
967961
Py_INCREF(input);
968962
return input;
969963
}
970964
return nfc_nfkc(self, input, 1);
971965
}
972-
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFD)) {
966+
if (PyUnicode_CompareWithASCIIString(form, "NFD") == 0) {
973967
if (is_normalized_quickcheck(self, input,
974968
false, false, true) == YES) {
975969
Py_INCREF(input);
976970
return input;
977971
}
978972
return nfd_nfkd(self, input, 0);
979973
}
980-
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKD)) {
974+
if (PyUnicode_CompareWithASCIIString(form, "NFKD") == 0) {
981975
if (is_normalized_quickcheck(self, input,
982976
false, true, true) == YES) {
983977
Py_INCREF(input);

0 commit comments

Comments
 (0)