diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-01-18 11:13:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 11:13:00 (GMT) |
commit | 8c2fd09f365e082cfceb29afdf38953cdd670946 (patch) | |
tree | cc4069c3a5bf9550dc855e92bc5bc1874df9230f | |
parent | 243c31667cc15a9a338330ad9b2a29b1cd1c76ec (diff) | |
download | cpython-8c2fd09f365e082cfceb29afdf38953cdd670946.zip cpython-8c2fd09f365e082cfceb29afdf38953cdd670946.tar.gz cpython-8c2fd09f365e082cfceb29afdf38953cdd670946.tar.bz2 |
bpo-46339: Include clarification on assert in 'get_error_line_from_tokenizer_buffers' (#30545)
-rw-r--r-- | Parser/pegen_errors.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c index bffae85..f348ac3 100644 --- a/Parser/pegen_errors.c +++ b/Parser/pegen_errors.c @@ -254,6 +254,9 @@ get_error_line_from_tokenizer_buffers(Parser *p, Py_ssize_t lineno) for (int i = 0; i < relative_lineno - 1; i++) { char *new_line = strchr(cur_line, '\n') + 1; + // The assert is here for debug builds but the conditional that + // follows is there so in release builds we do not crash at the cost + // to report a potentially wrong line. assert(new_line != NULL && new_line < p->tok->inp); if (new_line == NULL || new_line >= p->tok->inp) { break; |