Mercurial > cpython-lru_cache-weakref
diff Objects/typeobject.c @ 43074:db9a176190d3
Fix #1753395.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Thu, 30 Aug 2007 18:29:48 +0000 |
| parents | ed1594a16bdb |
| children | 4e6b4ba60c3b |
line wrap: on
line diff
--- a/Objects/typeobject.c Thu Aug 30 18:27:06 2007 +0000 +++ b/Objects/typeobject.c Thu Aug 30 18:29:48 2007 +0000 @@ -1561,28 +1561,16 @@ static int valid_identifier(PyObject *s) { - Py_UNICODE *p; - Py_ssize_t i, n; - if (!PyUnicode_Check(s)) { PyErr_Format(PyExc_TypeError, "__slots__ items must be strings, not '%.200s'", Py_Type(s)->tp_name); return 0; } - p = PyUnicode_AS_UNICODE(s); - n = PyUnicode_GET_SIZE(s); - /* We must reject an empty name. As a hack, we bump the - length to 1 so that the loop will balk on the trailing \0. */ - if (n == 0) - n = 1; - for (i = 0; i < n; i++, p++) { - if (*p > 127 || - (!(i == 0 ? isalpha(*p) : isalnum(*p)) && *p != '_')) { - PyErr_SetString(PyExc_TypeError, - "__slots__ must be identifiers"); - return 0; - } + if (!PyUnicode_IsIdentifier(s)) { + PyErr_SetString(PyExc_TypeError, + "__slots__ must be identifiers"); + return 0; } return 1; }
