Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RecursionError when iterating streams #1554

Merged
merged 2 commits into from
Feb 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,15 +695,14 @@ def __iter__(self) -> "Git.CatFileContentStream":
return self

def __next__(self) -> bytes:
return next(self)

def next(self) -> bytes:
line = self.readline()
if not line:
raise StopIteration

return line

next = __next__

Comment on lines +704 to +705
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to commit through the github UI if you want to drop this Python2 compatibility layer entirely:

Suggested change
next = __next__

Note that there may be some downstream code that relies on using next because __next__ was broken though!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. Oh well, let's be conservative then.

def __del__(self) -> None:
bytes_left = self._size - self._nbr
if bytes_left:
Expand Down