gh-91078: Return None from TarFile.next when the tarfile is empty (GH-91850)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Sam Ezeh 2022-11-26 17:57:05 +00:00 committed by GitHub
parent 7796d3179b
commit 78365b8e28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -2339,6 +2339,8 @@ class TarFile(object):
# Advance the file pointer.
if self.offset != self.fileobj.tell():
if self.offset == 0:
return None
self.fileobj.seek(self.offset - 1)
if not self.fileobj.read(1):
raise ReadError("unexpected end of data")