summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 9d00615..9bfad25 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -616,6 +616,22 @@ class ExFileObject(object):
"""Close the file object.
"""
self.closed = True
+
+ def __iter__(self):
+ """Get an iterator over the file object.
+ """
+ if self.closed:
+ raise ValueError("I/O operation on closed file")
+ return self
+
+ def next(self):
+ """Get the next item from the file iterator.
+ """
+ result = self.readline()
+ if not result:
+ raise StopIteration
+ return result
+
#class ExFileObject
#------------------