Gave hotshot.LogReader a close() method, to allow users to close the

file object that LogReader opens.  Used it then in test_hotshot; the
test passes again on Windows.  Thank Guido for the analysis.
This commit is contained in:
Tim Peters 2002-07-18 14:54:28 +00:00
parent 32616cf8ec
commit 30d4896511
2 changed files with 4 additions and 4 deletions

View File

@ -51,6 +51,9 @@ class LogReader:
self._append = self._stack.append self._append = self._stack.append
self._pop = self._stack.pop self._pop = self._stack.pop
def close(self):
self._reader.close()
def addinfo(self, key, value): def addinfo(self, key, value):
"""This method is called for each additional ADD_INFO record. """This method is called for each additional ADD_INFO record.

View File

@ -31,10 +31,7 @@ class UnlinkingLogReader(hotshot.log.LogReader):
try: try:
return hotshot.log.LogReader.next(self) return hotshot.log.LogReader.next(self)
except (IndexError, StopIteration): except (IndexError, StopIteration):
# XXX This fails on Windows because the named file is still self.close()
# 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.
os.unlink(self.__logfn) os.unlink(self.__logfn)
raise raise