From 7f143e1c5beec01ec3429aa4db12435ac02977d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= Date: Mon, 30 Dec 2024 12:48:42 +0100 Subject: [PATCH] Fix tests with Python 3.13 Properly implement the iterator protocol. --- pygit2/config.py | 9 +++------ pygit2/index.py | 7 ++----- pygit2/utils.py | 4 ++-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/pygit2/config.py b/pygit2/config.py index 8143a1f1..11c9b874 100644 --- a/pygit2/config.py +++ b/pygit2/config.py @@ -52,6 +52,9 @@ def __del__(self): def __iter__(self): return self + def __next__(self): + return self._next_entry() + def _next_entry(self): centry = ffi.new('git_config_entry **') err = C.git_config_next(centry, self._iter) @@ -59,12 +62,6 @@ def _next_entry(self): return ConfigEntry._from_c(centry[0], self) - def next(self): - return self.__next__() - - def __next__(self): - return self._next_entry() - class ConfigMultivarIterator(ConfigIterator): def __next__(self): diff --git a/pygit2/index.py b/pygit2/index.py index b06ae684..11e9eddb 100644 --- a/pygit2/index.py +++ b/pygit2/index.py @@ -467,8 +467,8 @@ def __init__(self, index): def __del__(self): C.git_index_conflict_iterator_free(self._iter) - def next(self): - return self.__next__() + def __iter__(self): + return self def __next__(self): cancestor = ffi.new('git_index_entry **') @@ -486,6 +486,3 @@ def __next__(self): theirs = IndexEntry._from_c(ctheirs[0]) return ancestor, ours, theirs - - def __iter__(self): - return self diff --git a/pygit2/utils.py b/pygit2/utils.py index 0660cc42..6a595e55 100644 --- a/pygit2/utils.py +++ b/pygit2/utils.py @@ -165,8 +165,8 @@ def __init__(self, container): self.length = len(container) self.idx = 0 - def next(self): - return self.__next__() + def __iter__(self): + return self def __next__(self): idx = self.idx