mirror of https://github.com/python/cpython
When printing an error message, don't choke if tok->buf is NULL.
This commit is contained in:
parent
64b4552069
commit
56b07c8ad9
|
@ -89,17 +89,21 @@ parsefile(fp, filename, g, start, ps1, ps2, n_ret)
|
||||||
char *p;
|
char *p;
|
||||||
fprintf(stderr, "Parsing error: file %s, line %d:\n",
|
fprintf(stderr, "Parsing error: file %s, line %d:\n",
|
||||||
filename, tok->lineno);
|
filename, tok->lineno);
|
||||||
*tok->inp = '\0';
|
if (tok->buf == NULL)
|
||||||
if (tok->inp > tok->buf && tok->inp[-1] == '\n')
|
fprintf(stderr, "(EOF)\n");
|
||||||
tok->inp[-1] = '\0';
|
else {
|
||||||
fprintf(stderr, "%s\n", tok->buf);
|
*tok->inp = '\0';
|
||||||
for (p = tok->buf; p < tok->cur; p++) {
|
if (tok->inp > tok->buf && tok->inp[-1] == '\n')
|
||||||
if (*p == '\t')
|
tok->inp[-1] = '\0';
|
||||||
putc('\t', stderr);
|
fprintf(stderr, "%s\n", tok->buf);
|
||||||
else
|
for (p = tok->buf; p < tok->cur; p++) {
|
||||||
putc(' ', stderr);
|
if (*p == '\t')
|
||||||
|
putc('\t', stderr);
|
||||||
|
else
|
||||||
|
putc(' ', stderr);
|
||||||
|
}
|
||||||
|
fprintf(stderr, "^\n");
|
||||||
}
|
}
|
||||||
fprintf(stderr, "^\n");
|
|
||||||
}
|
}
|
||||||
tok_free(tok);
|
tok_free(tok);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue