Skip to content

Commit

Permalink
[utils] mode might be None in write_string()
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkf committed Mar 11, 2024
1 parent 80cb917 commit 05aa2ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion youtube_dl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3495,7 +3495,8 @@ def write_string(s, out=None, encoding=None):
if _windows_write_string(s, out):
return

if ('b' in getattr(out, 'mode', '')
# `mode` might be `None` (see https://github.com/yt-dlp/yt-dlp/issues/8816)
if ('b' in (getattr(out, 'mode', None) or '')
or sys.version_info[0] < 3): # Python 2 lies about mode of sys.stderr
byt = s.encode(encoding or preferredencoding(), 'ignore')
out.write(byt)
Expand Down

0 comments on commit 05aa2ad

Please sign in to comment.