StreamLogWriter: Provide (no-op) close method. (#10884)
Some contexts try to close their reference to the stderr stream at logging shutdown, this ensures these don't break. * Make pylint happy An explicit `pass` is better here, but the docstring _is_ a statement. Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com>
This commit is contained in:
Родитель
3ee618623b
Коммит
26ae8e93e8
|
@ -93,6 +93,13 @@ class StreamLogWriter:
|
|||
self.level = level
|
||||
self._buffer = ''
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Provide close method, for compatibility with the io.IOBase interface.
|
||||
|
||||
This is a no-op method.
|
||||
"""
|
||||
|
||||
@property
|
||||
def closed(self): # noqa: D402
|
||||
"""
|
||||
|
|
|
@ -96,3 +96,10 @@ class TestStreamLogWriter(unittest.TestCase):
|
|||
|
||||
log = StreamLogWriter(logger, 1)
|
||||
self.assertIsNone(log.encoding)
|
||||
|
||||
def test_iobase_compatibility(self):
|
||||
log = StreamLogWriter(None, 1)
|
||||
|
||||
self.assertFalse(log.closed)
|
||||
# has no specific effect
|
||||
log.close()
|
||||
|
|
Загрузка…
Ссылка в новой задаче