diff options
author | Guido van Rossum <guido@python.org> | 2020-05-14 18:57:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 18:57:40 -0700 |
commit | 31641ff0e4b18c8d002d019f4506f0e8fb446983 (patch) | |
tree | f1328f26667420d26a0d1e1b8edd36f1e53e6867 | |
parent | 1c7e6bb160e3f25117ee3f13f9b751b46b477233 (diff) | |
download | cpython-git-31641ff0e4b18c8d002d019f4506f0e8fb446983.tar.gz |
Apply PEP 7 suggestions from code review
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
-rw-r--r-- | Python/pythonrun.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 0828e3cf3a..160f44d38e 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -570,21 +570,25 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj) /* Calculate text length excluding trailing newline */ Py_ssize_t len = strlen(text); - if (len > 0 && text[len-1] == '\n') + if (len > 0 && text[len-1] == '\n') { len--; + } /* Clip offset to at most len */ - if (offset > len) + if (offset > len) { offset = len; + } /* Skip past newlines embedded in text */ for (;;) { const char *nl = strchr(text, '\n'); - if (nl == NULL) + if (nl == NULL) { break; + } Py_ssize_t inl = nl - text; - if (inl >= (Py_ssize_t)offset) + if (inl >= (Py_ssize_t)offset) { break; + } inl += 1; text += inl; len -= inl; @@ -596,8 +600,9 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj) PyFile_WriteString(text, f); /* Make sure there's a newline at the end */ - if (text[len] != '\n') + if (text[len] != '\n') { PyFile_WriteString("\n", f); + } /* Don't print caret if it points to the left of the text */ if (offset < 0) @@ -605,8 +610,9 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj) /* Write caret line */ PyFile_WriteString(" ", f); - while (--offset >= 0) + while (--offset >= 0) { PyFile_WriteString(" ", f); + } PyFile_WriteString("^\n", f); } |