[Python-checkins] r82191 - in python/trunk: Include/pyctype.h Parser/tokenizer.c

stefan.krah python-checkins at python.org
Thu Jun 24 11:33:05 CEST 2010


Author: stefan.krah
Date: Thu Jun 24 11:33:05 2010
New Revision: 82191

Log:
Issue #9020: The Py_IS* macros from pyctype.h should generally only be
used with signed/unsigned char arguments. For integer arguments, EOF
has to be handled separately.



Modified:
   python/trunk/Include/pyctype.h
   python/trunk/Parser/tokenizer.c

Modified: python/trunk/Include/pyctype.h
==============================================================================
--- python/trunk/Include/pyctype.h	(original)
+++ python/trunk/Include/pyctype.h	Thu Jun 24 11:33:05 2010
@@ -11,6 +11,9 @@
 
 extern const unsigned int _Py_ctype_table[256];
 
+/* Unlike their C counterparts, the following macros are not meant to
+ * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument
+ * must be a signed/unsigned char. */
 #define Py_ISLOWER(c)  (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER)
 #define Py_ISUPPER(c)  (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER)
 #define Py_ISALPHA(c)  (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA)

Modified: python/trunk/Parser/tokenizer.c
==============================================================================
--- python/trunk/Parser/tokenizer.c	(original)
+++ python/trunk/Parser/tokenizer.c	Thu Jun 24 11:33:05 2010
@@ -1365,7 +1365,7 @@
                 goto letter_quote;
             break;
         }
-        while (Py_ISALNUM(c) || c == '_') {
+        while (c != EOF && (Py_ISALNUM(c) || c == '_')) {
             c = tok_nextc(tok);
         }
         tok_backup(tok, c);


More information about the Python-checkins mailing list