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

Skip to content

Commit dc8b569

Browse files
committed
Patch from Tim Peters to repare a the problem that tracebacks are off
by a line when Python is run with -x.
1 parent 9bcd1d7 commit dc8b569

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Modules/main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,15 @@ Py_Main(argc, argv)
197197
exit(2);
198198
}
199199
else if (skipfirstline) {
200-
char line[256];
201-
fgets(line, sizeof line, fp);
200+
int ch;
201+
/* Push back first newline so line numbers
202+
remain the same */
203+
while ((ch = getc(fp)) != EOF) {
204+
if (ch == '\n') {
205+
(void)ungetc(ch, fp);
206+
break;
207+
}
208+
}
202209
}
203210
}
204211
}

0 commit comments

Comments
 (0)