summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-10-29 03:28:14 +0000
committerBenjamin Peterson <benjamin@python.org>2010-10-29 03:28:14 +0000
commitd83461f3fbb6225b8b24dfcbd4c8cba26de8f263 (patch)
tree816e8fbe161c5d39a6a4a72594ade1646f2b7b24 /Python/pythonrun.c
parenta4f91f2b2e51582df08a6cceb77851abac28f5bb (diff)
downloadcpython-d83461f3fbb6225b8b24dfcbd4c8cba26de8f263.tar.gz
decrement offset when it points to a newline (#10186 followup)
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c4
1 files changed, 3 insertions, 1 deletions
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);
}