Skip to content

A feature-rich command-line audio/video downloader

[utils/_windows_write_string] Be defensive about fileno (Fixes #2820)

Philipp Hagemeistera383a98af617
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 2a93d3e34a..1036ea9bd8 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -926,7 +926,11 @@ def _windows_write_string(s, out):
2: -12,
}
- fileno = out.fileno()
+ try:
+ fileno = out.fileno()
+ except AttributeError:
+ # If the output stream doesn't have a fileno, it's virtual
+ return False
if fileno not in WIN_OUTPUT_IDS:
return False