Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 798199d

Browse files
committed
* Python/pythonrun.c (print_error): print only last line of
multi-line source line
1 parent 1a817c0 commit 798199d

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Python/pythonrun.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,18 @@ print_error()
286286
writestring(buf, f);
287287
writestring("\n", f);
288288
if (text != NULL) {
289+
char *nl;
290+
if (offset > 0 &&
291+
offset == strlen(text))
292+
offset--;
293+
for (;;) {
294+
nl = strchr(text, '\n');
295+
if (nl == NULL ||
296+
nl-text >= offset)
297+
break;
298+
offset -= (nl+1-text);
299+
text = nl+1;
300+
}
289301
while (*text == ' ' || *text == '\t') {
290302
text++;
291303
offset--;

0 commit comments

Comments
 (0)