diff options
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r-- | Parser/tokenizer.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index e52d498..9b269af 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -1269,6 +1269,7 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end) /* This is a type comment if we matched all of type_comment_prefix. */ if (!*prefix) { int is_type_ignore = 1; + const char *ignore_end = p + 6; tok_backup(tok, c); /* don't eat the newline or EOF */ type_start = p; @@ -1276,10 +1277,13 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end) /* A TYPE_IGNORE is "type: ignore" followed by the end of the token * or anything non-alphanumeric. */ is_type_ignore = ( - tok->cur >= p + 6 && memcmp(p, "ignore", 6) == 0 - && !(tok->cur > p + 6 && isalnum(p[6]))); + tok->cur >= ignore_end && memcmp(p, "ignore", 6) == 0 + && !(tok->cur > ignore_end && isalnum(p[6]))); if (is_type_ignore) { + *p_start = (char *) ignore_end; + *p_end = tok->cur; + /* If this type ignore is the only thing on the line, consume the newline also. */ if (blankline) { tok_nextc(tok); |