]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch from Tim Peters to repare a the problem that tracebacks are off
authorGuido van Rossum <guido@python.org>
Mon, 19 Apr 1999 17:54:19 +0000 (17:54 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 19 Apr 1999 17:54:19 +0000 (17:54 +0000)
by a line when Python is run with -x.

Modules/main.c

index 58df084c6bcc1621391e63c33e3db55081451998..65b22aa52b261fd9ae0648a46580a0d5a4171855 100644 (file)
@@ -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;
+                                       }
+                               }
                        }
                }
        }