On Mon, 18 Nov 2024 12:08:36 +0500 Andrey Rakhmatullin <w...@debian.org>
wrote:
I checked the upstream and found that the packaged version already claims
to support 3.13, and they indeed run 3.13 tests on CI. So this is weird.
Looking at the code of the GenericIterator class [1], the error is
correct: It's missing the __iter__() method that's required for
iterators. To quote the Python docs [2]:

Iterators are required to have an __iter__() method that returns the
iterator object itself so every iterator is also iterable and may be
used in most places where other iterables are accepted.
[...]
CPython implementation detail: CPython does not consistently apply
the requirement that an iterator define __iter__(). And also please
note that the free-threading CPython does not guarantee the thread-
safety of iterator operations.
I've reproduced the bug locally, and indeed patching in an __iter__
method solves the problem (patch attached). So this looks like an
upstream bug. I'd still be very curious exactly what about the "not
consistently" applied requirement doesn't trigger in the upstream tests
but does on Debian. :-)

[1]
https://github.com/libgit2/pygit2/blob/eba710e45bb40e18641c6531394bb46631e7f295/pygit2/utils.py#L156C7-L156C22
[2] https://docs.python.org/3.13/glossary.html#term-iterator
Description: Implement GenericIterator.__iter__()
 Fixes test failure with: TypeError: 'GenericIterator' object is not iterable

 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087432
---

--- python-pygit2-1.16.0.orig/pygit2/utils.py
+++ python-pygit2-1.16.0/pygit2/utils.py
@@ -175,3 +175,6 @@ class GenericIterator:
 
         self.idx += 1
         return self.container[idx]
+
+    def __iter__(self):
+        return self

Reply via email to