mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-03 08:19:57 +01:00
[utils] sanitize_open: Allow any IO stream as stdout
Fixes: https://github.com/yt-dlp/yt-dlp/issues/3298#issuecomment-1181754989
This commit is contained in:
parent
a6bcaf71fc
commit
daef791100
@ -598,6 +598,8 @@ def sanitize_open(filename, open_mode):
|
||||
if filename == '-':
|
||||
if sys.platform == 'win32':
|
||||
import msvcrt
|
||||
# stdout may be any IO stream. Eg, when using contextlib.redirect_stdout
|
||||
with contextlib.suppress(io.UnsupportedOperation):
|
||||
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
|
||||
return (sys.stdout.buffer if hasattr(sys.stdout, 'buffer') else sys.stdout, filename)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user