Whole file

mahmoud/boltons

The author described this change as fix IndexedSet out-of-range negative indexing wrapping around (x[-n-k], pop(-n-k)). It counts as a record because the checks below fail on the code as it stood at 609cabe93 and pass on d0a284fc7, with nothing else changed between the two runs.

Fix saved2026-07-16
Sharing licenceBSD-2-Clause · LICENSE
Change size+3 7

What the code was meant to do, written into the code itself as a save note

fix IndexedSet out-of-range negative indexing wrapping around (x[-n-k], pop(-n-k))

The change

158158 def _get_real_index(self, index):
159159 if index < 0:
160160 index += len(self)
161+ if index < 0 or index >= len(self):
162+ raise IndexError('IndexedSet index out of range')
161163 if not self.dead_indices:
162164 return index
163165 real_index = index
416418 else:
417419 iter_slice = self.iter_slice(start, stop, step)
418420 return self.from_iterable(iter_slice)
419- if index < 0:
420- index += len(self)
421421 real_index = self._get_real_index(index)
422- try:
423- ret = self.item_list[real_index]
424- except IndexError:
425- raise IndexError('IndexedSet index out of range')
426- return ret
422+ return self.item_list[real_index]
427423
428424 def pop(self, index=None):
429425 "pop(index) -> remove the item at a given index (-1 by default)"

The check that tells the two apart

failpass·tests/test_setutils.py::test_iset_scalar_index_bounds
failpass·tests/test_setutils.py::test_iset_scalar_index_multiple_dead_intervals

Check file tests/test_setutils.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it609cabe932a1ea1423b24568644945abb1b8bb84
Broken version dated2026-07-16
Moduleboltons.setutils
Units changedIndexedSet
Fingerprintd3421cf7d35b6315
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in mahmoud/boltons