1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-03-10 16:20:04 +01:00

[utils] write_string: Allow out.mode to be None

Closes #8816

Authored by: Grub4K
This commit is contained in:
Simon Sawicki 2024-01-27 06:26:31 +01:00
parent 03da517eb5
commit 7045ac8d87
No known key found for this signature in database

View File

@ -1424,7 +1424,8 @@ def write_string(s, out=None, encoding=None):
s = re.sub(r'([\r\n]+)', r' \1', s) s = re.sub(r'([\r\n]+)', r' \1', s)
enc, buffer = None, out enc, buffer = None, out
if 'b' in getattr(out, 'mode', ''): # `mode` might be `None` (Ref: https://github.com/yt-dlp/yt-dlp/issues/8816)
if 'b' in (getattr(out, 'mode', None) or ''):
enc = encoding or preferredencoding() enc = encoding or preferredencoding()
elif hasattr(out, 'buffer'): elif hasattr(out, 'buffer'):
buffer = out.buffer buffer = out.buffer