Skip to content

Commit

Permalink
Fix tests with Python 3.13
Browse files Browse the repository at this point in the history
Properly implement the iterator protocol.
  • Loading branch information
jdavid committed Dec 30, 2024
1 parent e75219d commit 7f143e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
9 changes: 3 additions & 6 deletions pygit2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,16 @@ 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)
check_error(err)

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):
Expand Down
7 changes: 2 additions & 5 deletions pygit2/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 **')
Expand All @@ -486,6 +486,3 @@ def __next__(self):
theirs = IndexEntry._from_c(ctheirs[0])

return ancestor, ours, theirs

def __iter__(self):
return self
4 changes: 2 additions & 2 deletions pygit2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f143e1

Please sign in to comment.