Skip to content

Commit 52d7ef2

Browse files
committed
Fix pystatx_result_repr()
Change the logic to write the comma.
1 parent 106c5ad commit 52d7ef2

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

Modules/posixmodule.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,31 +3529,24 @@ pystatx_result_repr(PyObject *op)
35293529
Py_DECREF(o);
35303530
}
35313531

3532-
if (Py_ARRAY_LENGTH(pystatx_result_members) > 1
3533-
&& Py_ARRAY_LENGTH(pystatx_result_getset) > 1) {
3534-
WRITE_ASCII(", ");
3535-
}
3536-
35373532
for (size_t i = 0; i < Py_ARRAY_LENGTH(pystatx_result_getset) - 1; ++i) {
35383533
PyGetSetDef *d = &pystatx_result_getset[i];
35393534
PyObject *o = d->get(op, d->closure);
35403535
if (o == NULL) {
35413536
goto error;
35423537
}
3538+
if (o == Py_None) {
3539+
continue;
3540+
}
35433541

3544-
if (o != Py_None) {
3545-
if (i > 0) {
3546-
WRITE_ASCII(", ");
3547-
}
3548-
3549-
WRITE_ASCII(d->name);
3550-
WRITE_ASCII("=");
3551-
if (PyUnicodeWriter_WriteRepr(writer, o) < 0) {
3552-
Py_DECREF(o);
3553-
goto error;
3554-
}
3542+
WRITE_ASCII(", ");
3543+
WRITE_ASCII(d->name);
3544+
WRITE_ASCII("=");
3545+
if (PyUnicodeWriter_WriteRepr(writer, o) < 0) {
35553546
Py_DECREF(o);
3547+
goto error;
35563548
}
3549+
Py_DECREF(o);
35573550
}
35583551

35593552
WRITE_ASCII(")");

0 commit comments

Comments
 (0)