If the Tee object is to be fully treated like a File-like object,
it needs to also implement the .closed property, per io.IOBase.closed.
If it doesn't, then the caller (in the base library) will fail to test the
property before trying to close the Tee object.
This was reproduced with a custom copy of nose where the Tee object
was duped to a logging.StreamHandler object, like seen below:
...
Traceback (most recent call last):
File "/usr/local/lib/python2.7/logging/__init__.py", line 892, in emit
self.flush()
File "/usr/local/lib/python2.7/logging/__init__.py", line 851, in flush
if self.stream and hasattr(self.stream, "flush") and not self.stream.closed:
AttributeError: 'Tee' object has no attribute 'closed'
Logged from file (unknown file), line 0
Ancillary Changes
These changes also address some minor stylistic issues found by flake8, in
part by using the black tool to reformat the file.
Core Change
If the
Tee
object is to be fully treated like aFile
-like object, it needs to also implement the.closed
property, per io.IOBase.closed. If it doesn't, then the caller (in the base library) will fail to test the property before trying to close theTee
object.This was reproduced with a custom copy of nose where the Tee object was duped to a
logging.StreamHandler
object, like seen below:Ancillary Changes
These changes also address some minor stylistic issues found by flake8, in part by using the black tool to reformat the file.
Signed-off-by: Enji Cooper yaneurabeya@gmail.com