diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-10-29 03:28:14 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-10-29 03:28:14 (GMT) |
commit | a95e977e41ca13ac2677c455e5270cf4018f5838 (patch) | |
tree | 8e8e411caf136db1cbad5ec2f5010930f12f3ebe /Python/pythonrun.c | |
parent | 47ce965562e5a767a523b9c0ae71bf0603f5bee8 (diff) | |
download | cpython-a95e977e41ca13ac2677c455e5270cf4018f5838.zip cpython-a95e977e41ca13ac2677c455e5270cf4018f5838.tar.gz cpython-a95e977e41ca13ac2677c455e5270cf4018f5838.tar.bz2 |
decrement offset when it points to a newline (#10186 followup)
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 1b0a84b..33dd11b 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1344,6 +1344,8 @@ print_error_text(PyObject *f, int offset, const char *text) { char *nl; if (offset >= 0) { + if (offset > 0 && offset == strlen(text) && text[offset - 1] == '\n') + offset--; for (;;) { nl = strchr(text, '\n'); if (nl == NULL || nl-text >= offset) @@ -1363,7 +1365,7 @@ print_error_text(PyObject *f, int offset, const char *text) if (offset == -1) return; PyFile_WriteString(" ", f); - while (--offset) + while (--offset > 0) PyFile_WriteString(" ", f); PyFile_WriteString("^\n", f); } |