Skip to content

Commit 7f143e1

Browse files
committedDec 30, 2024·
Fix tests with Python 3.13
Properly implement the iterator protocol.
1 parent e75219d commit 7f143e1

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed
 

‎pygit2/config.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,16 @@ def __del__(self):
5252
def __iter__(self):
5353
return self
5454

55+
def __next__(self):
56+
return self._next_entry()
57+
5558
def _next_entry(self):
5659
centry = ffi.new('git_config_entry **')
5760
err = C.git_config_next(centry, self._iter)
5861
check_error(err)
5962

6063
return ConfigEntry._from_c(centry[0], self)
6164

62-
def next(self):
63-
return self.__next__()
64-
65-
def __next__(self):
66-
return self._next_entry()
67-
6865

6966
class ConfigMultivarIterator(ConfigIterator):
7067
def __next__(self):

‎pygit2/index.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ def __init__(self, index):
467467
def __del__(self):
468468
C.git_index_conflict_iterator_free(self._iter)
469469

470-
def next(self):
471-
return self.__next__()
470+
def __iter__(self):
471+
return self
472472

473473
def __next__(self):
474474
cancestor = ffi.new('git_index_entry **')
@@ -486,6 +486,3 @@ def __next__(self):
486486
theirs = IndexEntry._from_c(ctheirs[0])
487487

488488
return ancestor, ours, theirs
489-
490-
def __iter__(self):
491-
return self

‎pygit2/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def __init__(self, container):
165165
self.length = len(container)
166166
self.idx = 0
167167

168-
def next(self):
169-
return self.__next__()
168+
def __iter__(self):
169+
return self
170170

171171
def __next__(self):
172172
idx = self.idx

0 commit comments

Comments
 (0)
Please sign in to comment.