From: Guido van Rossum Date: Mon, 19 Apr 1999 17:54:19 +0000 (+0000) Subject: Patch from Tim Peters to repare a the problem that tracebacks are off X-Git-Tag: v1.6a1~1585 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc8b56915534b15668d9f40d499b60934292b4d4;p=thirdparty%2FPython%2Fcpython.git Patch from Tim Peters to repare a the problem that tracebacks are off by a line when Python is run with -x. --- diff --git a/Modules/main.c b/Modules/main.c index 58df084c6bcc..65b22aa52b26 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -197,8 +197,15 @@ Py_Main(argc, argv) exit(2); } else if (skipfirstline) { - char line[256]; - fgets(line, sizeof line, fp); + int ch; + /* Push back first newline so line numbers + remain the same */ + while ((ch = getc(fp)) != EOF) { + if (ch == '\n') { + (void)ungetc(ch, fp); + break; + } + } } } }