Skip to content

Commit 8c2fd09

Browse files
authored
bpo-46339: Include clarification on assert in 'get_error_line_from_tokenizer_buffers' (#30545)
1 parent 243c316 commit 8c2fd09

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Parser/pegen_errors.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ get_error_line_from_tokenizer_buffers(Parser *p, Py_ssize_t lineno)
254254

255255
for (int i = 0; i < relative_lineno - 1; i++) {
256256
char *new_line = strchr(cur_line, '\n') + 1;
257+
// The assert is here for debug builds but the conditional that
258+
// follows is there so in release builds we do not crash at the cost
259+
// to report a potentially wrong line.
257260
assert(new_line != NULL && new_line < p->tok->inp);
258261
if (new_line == NULL || new_line >= p->tok->inp) {
259262
break;

0 commit comments

Comments
 (0)