瀏覽代碼

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

Philipp Hagemeister 11 年之前
父節點
當前提交
a383a98af6
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      youtube_dl/utils.py

+ 5 - 1
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