Skip to content

Commit 7e5b824

Browse files
authored
Avoid attempt to write to wrong pipe (#44)
Do not attempt to write to pipe object unless it has a write attribute. This should avoid a runtime error like: AttributeError: 'int' object has no attribute 'write' Observed while testing use inside ansible-compat.
1 parent a8cec8e commit 7e5b824

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/subprocess_tee/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def _stream_subprocess(args: str, **kwargs: Any) -> CompletedProcess:
7474
def tee_func(line: bytes, sink: List[str], pipe: Optional[Any]) -> None:
7575
line_str = line.decode("utf-8").rstrip()
7676
sink.append(line_str)
77-
if not kwargs.get("quiet", False):
77+
if not kwargs.get("quiet", False) and hasattr(pipe, "write"):
7878
print(line_str, file=pipe)
7979

8080
loop = asyncio.get_event_loop()

0 commit comments

Comments
 (0)