Skip to content

Commit

Permalink
updater: workaround CPython bug 128211
Browse files Browse the repository at this point in the history
Python 3.13 list comprehensions are buggy [1]: [i for i in x] calls
iter(iter(x)) instead of just iter(x).  Work around the bug by having
UpdateListIter have a __iter__(self) that just returns self.  This is
the same thing that the standard library does:

    x = iter([])
    print(x is iter(x))

prints True.

[1]: python/cpython#128211
  • Loading branch information
DemiMarie committed Dec 24, 2024
1 parent a3e4d17 commit c920daf
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 c920daf

Please sign in to comment.