Skip to content

Commit eb28df7

Browse files
committed
ENH: 🐍
Special case the identifier validation to allow 🐍 to be used in identifiers
1 parent 62c7d90 commit eb28df7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

β€ŽObjects/unicodeobject.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12125,7 +12125,7 @@ PyUnicode_IsIdentifier(PyObject *self)
1212512125
int kind;
1212612126
void *data;
1212712127
Py_ssize_t i;
12128-
Py_UCS4 first;
12128+
Py_UCS4 chr;
1212912129

1213012130
if (PyUnicode_READY(self) == -1) {
1213112131
Py_FatalError("identifier not ready");
@@ -12146,13 +12146,17 @@ PyUnicode_IsIdentifier(PyObject *self)
1214612146
definition of XID_Start and XID_Continue, it is sufficient
1214712147
to check just for these, except that _ must be allowed
1214812148
as starting an identifier. */
12149-
first = PyUnicode_READ(kind, data, 0);
12150-
if (!_PyUnicode_IsXidStart(first) && first != 0x5F /* LOW LINE */)
12149+
chr = PyUnicode_READ(kind, data, 0);
12150+
if (!_PyUnicode_IsXidStart(chr) && chr != 0x5F /* LOW LINE */ && chr != 0x1F40D)
1215112151
return 0;
1215212152

1215312153
for (i = 1; i < PyUnicode_GET_LENGTH(self); i++)
12154-
if (!_PyUnicode_IsXidContinue(PyUnicode_READ(kind, data, i)))
12154+
{
12155+
chr = PyUnicode_READ(kind, data, i);
12156+
if (!_PyUnicode_IsXidContinue(chr) && chr != 0x1F40D)
1215512157
return 0;
12158+
}
12159+
1215612160
return 1;
1215712161
}
1215812162

0 commit comments

Comments
Β (0)