]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46339: Include clarification on assert in 'get_error_line_from_tokenizer_buffers...
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Tue, 18 Jan 2022 11:13:00 +0000 (11:13 +0000)
committerGitHub <noreply@github.com>
Tue, 18 Jan 2022 11:13:00 +0000 (11:13 +0000)
Parser/pegen_errors.c

index bffae8532ca2b7e9efa3f7729f897e89e13bef08..f348ac3000ddaf469f7b3cc6c1cf579a92c584ca 100644 (file)
@@ -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;