Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pep7 rest of function
  • Loading branch information
kristjanvalur committed Jan 7, 2024
commit 2398a99998ca147817d0e1550f39529290d30077
12 changes: 8 additions & 4 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2677,13 +2677,15 @@ list_index_impl(PyListObject *self, PyObject *value, Py_ssize_t start,

if (start < 0) {
start += Py_SIZE(self);
if (start < 0)
if (start < 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen other comments, but I have an oposite opinion: diff should be as minimal as possible. This is just a comment, no action needed, unless others also agree :)

@kristjanvalur kristjanvalur Jan 8, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I respectfully disagree, the style should be consistent within the function. Either I convert the entire function to pep7, or stick to the existing style. Which should it be? Also, it is a bit hard to try to follow disagreeing opinions of reviewers.

start = 0;
}
}
if (stop < 0) {
stop += Py_SIZE(self);
if (stop < 0)
if (stop < 0) {
stop = 0;
}
}
for (i = start; i < stop && i < Py_SIZE(self); i++) {
PyObject *obj, *item = self->ob_item[i];
Expand All @@ -2701,10 +2703,12 @@ list_index_impl(PyListObject *self, PyObject *value, Py_ssize_t start,
}
int cmp = PyObject_RichCompareBool(obj, value, Py_EQ);
Py_DECREF(obj);
if (cmp > 0)
if (cmp > 0) {
return PyLong_FromSsize_t(i);
else if (cmp < 0)
}
else if (cmp < 0) {
return NULL;
}
}
PyErr_Format(PyExc_ValueError, "%R is not in list", value);
return NULL;
Expand Down