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 Dec 31, 2024
1 parent a3e4d17 commit 41ba839
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 @@ -264,6 +264,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 268 in qui/updater/utils.py

View check run for this annotation

Codecov / codecov/patch

qui/updater/utils.py#L268

Added line #L268 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 41ba839

Please sign in to comment.