diff options
author | Guido van Rossum <guido@python.org> | 1999-04-19 17:54:19 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-04-19 17:54:19 (GMT) |
commit | dc8b56915534b15668d9f40d499b60934292b4d4 (patch) | |
tree | 7e1676e5f588f924850a5805b9fd42689e36f925 | |
parent | 9bcd1d7931f32fdc4a677aacd0c0f4932b22118b (diff) | |
download | cpython-dc8b56915534b15668d9f40d499b60934292b4d4.zip cpython-dc8b56915534b15668d9f40d499b60934292b4d4.tar.gz cpython-dc8b56915534b15668d9f40d499b60934292b4d4.tar.bz2 |
Patch from Tim Peters to repare a the problem that tracebacks are off
by a line when Python is run with -x.
-rw-r--r-- | Modules/main.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/main.c b/Modules/main.c index 58df084..65b22aa 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; + } + } } } } |