Skip to content

Commit 2cac26b

Browse files
Simplify groupby re-entrancy test
1 parent 4f2338f commit 2cac26b

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

Lib/test/test_itertools.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,7 @@ def __eq__(self, other):
742742
next(g)
743743
return False
744744

745-
data = [Key(b"a"), Key(b"b")]
746-
747-
g = itertools.groupby(data)
745+
g = itertools.groupby([Key(b"a"), Key(b"b")])
748746
next(g)
749747
next(g) # must not segfault
750748

Modules/itertoolsmodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,6 @@ groupby_next(PyObject *op)
544544
else if (gbo->tgtkey == NULL)
545545
break;
546546
else {
547-
int rcmp;
548547

549548
/* A user-defined __eq__ can re-enter groupby and advance the iterator,
550549
mutating gbo->tgtkey / gbo->currkey while we are comparing them.
@@ -556,7 +555,7 @@ groupby_next(PyObject *op)
556555
Py_INCREF(tgtkey);
557556
Py_INCREF(currkey);
558557

559-
rcmp = PyObject_RichCompareBool(tgtkey, currkey, Py_EQ);
558+
int rcmp = PyObject_RichCompareBool(tgtkey, currkey, Py_EQ);
560559

561560
Py_DECREF(tgtkey);
562561
Py_DECREF(currkey);

0 commit comments

Comments
 (0)