mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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:
parent
7796d3179b
commit
78365b8e28
3 changed files with 15 additions and 0 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue