]> granicus.if.org Git - python/commitdiff
Issue #9020: The Py_IS* macros from pyctype.h should generally only be
authorStefan Krah <stefan@bytereef.org>
Thu, 24 Jun 2010 09:33:05 +0000 (09:33 +0000)
committerStefan Krah <stefan@bytereef.org>
Thu, 24 Jun 2010 09:33:05 +0000 (09:33 +0000)
used with signed/unsigned char arguments. For integer arguments, EOF
has to be handled separately.

Include/pyctype.h
Parser/tokenizer.c

index 0d211ec799c77b80a0b935ef2d18f86640a918fd..c5cc61431d08e0cc8e3b58511b4d618b154c42de 100644 (file)
@@ -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)
index a647d9c4297ddbe5b08b7a9a4dbd42e8c7b8cbd6..ee6313b311d587521c2c9fa9d30fd697ff79ea95 100644 (file)
@@ -1365,7 +1365,7 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
                 goto letter_quote;
             break;
         }
-        while (Py_ISALNUM(c) || c == '_') {
+        while (c != EOF && (Py_ISALNUM(c) || c == '_')) {
             c = tok_nextc(tok);
         }
         tok_backup(tok, c);