aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-02-17 19:21:59 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-02-17 19:21:59 +0530
commit5c104538270e5fc5ff8cf1007c34c0bf1e82e003 (patch)
tree91162f55afbca22b1281c73b2a278973f0865b9d
parentffa89477ea588f610468f582f2d092bf992ad896 (diff)
downloadhypervideo-pre-5c104538270e5fc5ff8cf1007c34c0bf1e82e003.tar.lz
hypervideo-pre-5c104538270e5fc5ff8cf1007c34c0bf1e82e003.tar.xz
hypervideo-pre-5c104538270e5fc5ff8cf1007c34c0bf1e82e003.zip
Fix for when stdout/stderr encoding is None
Closes #2711
-rw-r--r--yt_dlp/YoutubeDL.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 1c3f9ba1e..8041b8d15 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -888,7 +888,8 @@ class YoutubeDL(object):
def _format_text(self, handle, allow_colors, text, f, fallback=None, *, test_encoding=False):
if test_encoding:
original_text = text
- encoding = self.params.get('encoding') or getattr(handle, 'encoding', 'ascii')
+ # handle.encoding can be None. See https://github.com/yt-dlp/yt-dlp/issues/2711
+ encoding = self.params.get('encoding') or getattr(handle, 'encoding', None) or 'ascii'
text = text.encode(encoding, 'ignore').decode(encoding)
if fallback is not None and text != original_text:
text = fallback