From 41ba839ab71b7c331bdf9e4797d2f13d0cd7983a Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Sun, 22 Dec 2024 16:13:06 -0500 Subject: [PATCH] updater: make UpdateListIter a proper iterator 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]: https://github.com/python/cpython/issues/128211 --- qui/updater/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qui/updater/utils.py b/qui/updater/utils.py index 2a646521..fce7cced 100644 --- a/qui/updater/utils.py +++ b/qui/updater/utils.py @@ -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 + def __next__(self) -> RowWrapper: self._id += 1 if 0 <= self._id < len(self.list_store_wrapped):