8000 Gave hotshot.LogReader a close() method, to allow users to close the · python/cpython@30d4896 · GitHub
[go: up one dir, main page]

Skip to content

Commit 30d4896

Browse files
committed
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.
1 parent 32616cf commit 30d4896

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/hotshot/log.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def __init__(self, logfn):
5151
self._append = self._stack.append
5252
self._pop = self._stack.pop
5353

54+
def close(self):
55+
self._reader.close()
56+
5457
def addinfo(self, key, value):
5558
"""This method is called for each additional ADD_INFO record.
5659

Lib/test/test_hotshot.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ def next(self, index=None):
3131
try:
3232
return hotshot.log.LogReader.next(self)
3333
except (IndexError, StopIteration):
34-
# XXX This fails on Windows because the named file is still
35-
# XXX open. Offhand I couldn't find an appropriate way to close
36-
# XXX the file object, or even where the heck it is. LogReader
37-
# XXX in particular doesn't have a close() method.
34+
self.close()
3835
os.unlink(self.__logfn)
3936
raise
4037

0 commit comments

Comments
 (0)
0