Georg Brandl added the comment:

Attaching a patch, should fix this.

----------
nosy: +gbrandl

_____________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1753395>
_____________________________________
Index: Objects/typeobject.c
===================================================================
--- Objects/typeobject.c        (Revision 57337)
+++ Objects/typeobject.c        (Arbeitskopie)
@@ -1563,28 +1563,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;
 }
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to