Mailing List Archive

bpo-46339: Include clarification on assert in 'get_error_line_from_tokenizer_buffers' (#30545)
https://github.com/python/cpython/commit/8c2fd09f365e082cfceb29afdf38953cdd670946
commit: 8c2fd09f365e082cfceb29afdf38953cdd670946
branch: main
author: Pablo Galindo Salgado <Pablogsal@gmail.com>
committer: pablogsal <Pablogsal@gmail.com>
date: 2022-01-18T11:13:00Z
summary:

bpo-46339: Include clarification on assert in 'get_error_line_from_tokenizer_buffers' (#30545)

files:
M Parser/pegen_errors.c

diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c
index bffae8532ca2b..f348ac3000dda 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;

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins