]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Gave hotshot.LogReader a close() method, to allow users to close the
authorTim Peters <tim.peters@gmail.com>
Thu, 18 Jul 2002 14:54:28 +0000 (14:54 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 18 Jul 2002 14:54:28 +0000 (14:54 +0000)
file object that LogReader opens.  Used it then in test_hotshot; the
test passes again on Windows.  Thank Guido for the analysis.

Lib/hotshot/log.py
Lib/test/test_hotshot.py

index 335fff90fffaca8a484f9f4c20af75dcae453e26..9084461c290f849fb403bf059454ad65a19a2b3c 100644 (file)
@@ -51,6 +51,9 @@ class LogReader:
         self._append = self._stack.append
         self._pop = self._stack.pop
 
+    def close(self):
+        self._reader.close()
+
     def addinfo(self, key, value):
         """This method is called for each additional ADD_INFO record.
 
index db3c914b5bfc51b7dc261f874b903bf76d6aeb5e..2a45a7f527c80396864ebe0db6fe31590cea3274 100644 (file)
@@ -31,10 +31,7 @@ class UnlinkingLogReader(hotshot.log.LogReader):
         try:
             return hotshot.log.LogReader.next(self)
         except (IndexError, StopIteration):
-            # XXX This fails on Windows because the named file is still
-            # XXX open.  Offhand I couldn't find an appropriate way to close
-            # XXX the file object, or even where the heck it is.  LogReader
-            # XXX in particular doesn't have a close() method.
+            self.close()
             os.unlink(self.__logfn)
             raise