File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1561,28 +1561,16 @@ static PyGetSetDef subtype_getsets_weakref_only[] = {
15611561static int
15621562valid_identifier (PyObject * s )
15631563{
1564- Py_UNICODE * p ;
1565- Py_ssize_t i , n ;
1566-
15671564 if (!PyUnicode_Check (s )) {
15681565 PyErr_Format (PyExc_TypeError ,
15691566 "__slots__ items must be strings, not '%.200s'" ,
15701567 Py_Type (s )-> tp_name );
15711568 return 0 ;
15721569 }
1573- p = PyUnicode_AS_UNICODE (s );
1574- n = PyUnicode_GET_SIZE (s );
1575- /* We must reject an empty name. As a hack, we bump the
1576- length to 1 so that the loop will balk on the trailing \0. */
1577- if (n == 0 )
1578- n = 1 ;
1579- for (i = 0 ; i < n ; i ++ , p ++ ) {
1580- if (* p > 127 ||
1581- (!(i == 0 ? isalpha (* p ) : isalnum (* p )) && * p != '_' )) {
1582- PyErr_SetString (PyExc_TypeError ,
1583- "__slots__ must be identifiers" );
1584- return 0 ;
1585- }
1570+ if (!PyUnicode_IsIdentifier (s )) {
1571+ PyErr_SetString (PyExc_TypeError ,
1572+ "__slots__ must be identifiers" );
1573+ return 0 ;
15861574 }
15871575 return 1 ;
15881576}
You can’t perform that action at this time.
0 commit comments