Skip to content

Commit 9d97701

Browse files
Use contextlib.closing.
1 parent cc46702 commit 9d97701

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

Lib/test/test_logging.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import codecs
2727
import configparser
28+
import contextlib
2829
import copy
2930
import datetime
3031
import pathlib
@@ -6387,10 +6388,8 @@ def other_side():
63876388
with threading_helper.start_threads([thread]):
63886389
rh = logging.handlers.RotatingFileHandler(
63896390
filename, encoding="utf-8", maxBytes=1)
6390-
try:
6391+
with contextlib.closing(rh):
63916392
self.assertFalse(rh.shouldRollover(self.next_rec()))
6392-
finally:
6393-
rh.close()
63946393

63956394
def test_should_rollover(self):
63966395
with open(self.fn, 'wb') as f:

0 commit comments

Comments
 (0)