From 1231efc77c051f919f13be33cd2deb788b348f98 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 aaefb7f..d45e1fe 100644 --- a/qui/updater/utils.py +++ b/qui/updater/utils.py @@ -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 + def __next__(self) -> RowWrapper: self._id += 1 if 0 <= self._id < len(self.list_store_wrapped):