[Python-3000-checkins] r58690 - python/branches/py3k-pep3137/Objects/codeobject.c
guido.van.rossum
python-3000-checkins at python.org
Sat Oct 27 18:24:06 CEST 2007
Author: guido.van.rossum
Date: Sat Oct 27 18:24:06 2007
New Revision: 58690
Modified:
python/branches/py3k-pep3137/Objects/codeobject.c
Log:
Intern PyUnicode, not PyString when creating a code object.
Modified: python/branches/py3k-pep3137/Objects/codeobject.c
==============================================================================
--- python/branches/py3k-pep3137/Objects/codeobject.c (original)
+++ python/branches/py3k-pep3137/Objects/codeobject.c Sat Oct 27 18:24:06 2007
@@ -8,7 +8,7 @@
/* all_name_chars(s): true iff all chars in s are valid NAME_CHARS */
static int
-all_name_chars(unsigned char *s)
+all_name_chars(Py_UNICODE *s)
{
static char ok_name_char[256];
static unsigned char *name_chars = (unsigned char *)NAME_CHARS;
@@ -19,6 +19,8 @@
ok_name_char[*p] = 1;
}
while (*s) {
+ if (*s >= 128)
+ return 0;
if (ok_name_char[*s++] == 0)
return 0;
}
@@ -73,11 +75,11 @@
/* Intern selected string constants */
for (i = PyTuple_Size(consts); --i >= 0; ) {
PyObject *v = PyTuple_GetItem(consts, i);
- if (!PyString_Check(v))
+ if (!PyUnicode_Check(v))
continue;
- if (!all_name_chars((unsigned char *)PyString_AS_STRING(v)))
+ if (!all_name_chars(PyUnicode_AS_UNICODE(v)))
continue;
- PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i));
+ PyUnicode_InternInPlace(&PyTuple_GET_ITEM(consts, i));
}
co = PyObject_NEW(PyCodeObject, &PyCode_Type);
if (co != NULL) {
More information about the Python-3000-checkins
mailing list