Skip to content

Commit 6e416c6

Browse files
committed
reduce nesting
1 parent 35a6a29 commit 6e416c6

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

Objects/exceptions.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,24 +1873,22 @@ ImportError_repr(PyObject *self)
18731873
PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
18741874
if (writer == NULL) goto error;
18751875
if (PyUnicodeWriter_WriteSubstring(writer, r, 0, PyUnicode_GET_LENGTH(r)-1) < 0) goto error;
1876-
if (r && (exc->name || exc->path)) {
1877-
if (exc->name) {
1878-
if (hasargs) {
1879-
if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) goto error;
1880-
}
1881-
if (PyUnicodeWriter_WriteASCII(writer, "name='", 6) < 0) goto error;
1882-
if (PyUnicodeWriter_WriteSubstring(writer, exc->name, 0, PyUnicode_GET_LENGTH(exc->name)) < 0) goto error;
1883-
if (PyUnicodeWriter_WriteASCII(writer, "'", 1) < 0) goto error;
1884-
hasargs = 1;
1876+
if (exc->name) {
1877+
if (hasargs) {
1878+
if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) goto error;
18851879
}
1886-
if (exc->path) {
1887-
if (hasargs) {
1888-
if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) goto error;
1889-
}
1890-
if (PyUnicodeWriter_WriteASCII(writer, "path='", 6) < 0) goto error;
1891-
if (PyUnicodeWriter_WriteSubstring(writer, exc->path, 0, PyUnicode_GET_LENGTH(exc->path)) < 0) goto error;
1892-
if (PyUnicodeWriter_WriteASCII(writer, "'", 1) < 0) goto error;
1880+
if (PyUnicodeWriter_WriteASCII(writer, "name='", 6) < 0) goto error;
1881+
if (PyUnicodeWriter_WriteSubstring(writer, exc->name, 0, PyUnicode_GET_LENGTH(exc->name)) < 0) goto error;
1882+
if (PyUnicodeWriter_WriteASCII(writer, "'", 1) < 0) goto error;
1883+
hasargs = 1;
1884+
}
1885+
if (exc->path) {
1886+
if (hasargs) {
1887+
if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) goto error;
18931888
}
1889+
if (PyUnicodeWriter_WriteASCII(writer, "path='", 6) < 0) goto error;
1890+
if (PyUnicodeWriter_WriteSubstring(writer, exc->path, 0, PyUnicode_GET_LENGTH(exc->path)) < 0) goto error;
1891+
if (PyUnicodeWriter_WriteASCII(writer, "'", 1) < 0) goto error;
18941892
}
18951893
if (PyUnicodeWriter_WriteASCII(writer, ")", 1) < 0) goto error;
18961894
return PyUnicodeWriter_Finish(writer);

0 commit comments

Comments
 (0)