summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorSam Ezeh <sam.z.ezeh@gmail.com>2022-11-26 17:57:05 (GMT)
committerGitHub <noreply@github.com>2022-11-26 17:57:05 (GMT)
commit78365b8e283c78e23725748500f48dd2c2ca1161 (patch)
tree3f6a48fa957262380ec71700e39737deb139f109 /Lib/tarfile.py
parent7796d3179b71536dd1d2ca7fdbc1255bdb8cfb52 (diff)
downloadcpython-78365b8e283c78e23725748500f48dd2c2ca1161.zip
cpython-78365b8e283c78e23725748500f48dd2c2ca1161.tar.gz
cpython-78365b8e283c78e23725748500f48dd2c2ca1161.tar.bz2
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>
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-xLib/tarfile.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 42100e9..b47015f 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -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")