Skip to content

Commit

Permalink
updater: make UpdateListIter a proper iterator
Browse files Browse the repository at this point in the history
Python iterators are required to implement an __iter__() that returns
self [1].  CPython doesn't check this consistently, but the requirement
is still there, so the existing code is buggy.  Python 3.13 started
checking this in list comprehensions, resulting in exceptions being
thrown.  Fix the bug by having __iter__() return self, as required by
the iterator protocol.

This worked on Python 3.13 and below, but broke in 3.13.1 [2].

[1]: https://docs.python.org/3/glossary.html#term-iterator
[2]: python/cpython#128211
  • Loading branch information
DemiMarie committed Jan 4, 2025
1 parent 2b12854 commit 1231efc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qui/updater/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ def __init__(self, list_store_wrapped):
self.list_store_wrapped = list_store_wrapped
self._id = -1

def __iter__(self) -> "UpdateListIter":
return self

Check warning on line 278 in qui/updater/utils.py

View check run for this annotation

Codecov / codecov/patch

qui/updater/utils.py#L278

Added line #L278 was not covered by tests

def __next__(self) -> RowWrapper:
self._id += 1
if 0 <= self._id < len(self.list_store_wrapped):
Expand Down

0 comments on commit 1231efc

Please sign in to comment.