diff options
author | Michael J. Sullivan <sully@msully.net> | 2019-05-22 20:43:37 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-05-22 20:43:36 (GMT) |
commit | d8a82e2897b735e2b7e9e086f1d709365a2ad72c (patch) | |
tree | 205e3c569ca3d23346a4a8e3aa7bba46d352a7df /Parser | |
parent | 0c2b6a3943aa7b022e8eb4bfd9bffcddebf9a587 (diff) | |
download | cpython-d8a82e2897b735e2b7e9e086f1d709365a2ad72c.zip cpython-d8a82e2897b735e2b7e9e086f1d709365a2ad72c.tar.gz cpython-d8a82e2897b735e2b7e9e086f1d709365a2ad72c.tar.bz2 |
bpo-36878: Only allow text after `# type: ignore` if first character ASCII (GH-13504)
This disallows things like `# type: ignoreƩ`, which seems wrong.
Also switch to using Py_ISALNUM for the alnum check, for consistency
with other code (and maybe correctness re: locale issues?).
https://bugs.python.org/issue36878
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/tokenizer.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 9b269af..c2ec659 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -1275,10 +1275,11 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end) type_start = p; /* A TYPE_IGNORE is "type: ignore" followed by the end of the token - * or anything non-alphanumeric. */ + * or anything ASCII and non-alphanumeric. */ is_type_ignore = ( tok->cur >= ignore_end && memcmp(p, "ignore", 6) == 0 - && !(tok->cur > ignore_end && isalnum(p[6]))); + && !(tok->cur > ignore_end + && ((unsigned char)ignore_end[0] >= 128 || Py_ISALNUM(ignore_end[0])))); if (is_type_ignore) { *p_start = (char *) ignore_end; |