From a95e977e41ca13ac2677c455e5270cf4018f5838 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 29 Oct 2010 03:28:14 +0000 Subject: decrement offset when it points to a newline (#10186 followup) --- Python/pythonrun.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 1b0a84bd65..33dd11bc88 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); } -- cgit v1.2.1