[Python-checkins] python/dist/src/Lib tarfile.py,1.23,1.24

loewis at users.sourceforge.net loewis at users.sourceforge.net
Thu Mar 3 09:18:05 CET 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30564/Lib

Modified Files:
	tarfile.py 
Log Message:
Patch #1107973: tarfile.ExFileObject iterators.


Index: tarfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- tarfile.py	16 Jan 2005 00:16:11 -0000	1.23
+++ tarfile.py	3 Mar 2005 08:17:32 -0000	1.24
@@ -616,6 +616,22 @@
         """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
 
 #------------------



More information about the Python-checkins mailing list