Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base64IO: set write buffer before doing attr check #1377

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ansible_runner/utils/base64io.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def __init__(self, wrapped: IO) -> None:

:raises TypeError: if ``wrapped`` does not have attributes needed to determine the stream's state
"""
# set before the attr check as we may reach close() after that
# check fails
self.__write_buffer = b""
required_attrs = ("read", "write", "close", "closed", "flush")
if not all(hasattr(wrapped, attr) for attr in required_attrs):
raise TypeError(
Expand All @@ -86,7 +89,6 @@ def __init__(self, wrapped: IO) -> None:
super().__init__()
self.__wrapped = wrapped
self.__read_buffer = b""
self.__write_buffer = b""

def __enter__(self):
"""Return self on enter."""
Expand Down
Loading