diff options
author | dirkf <fieldhouse@gmx.net> | 2023-04-05 18:39:54 +0100 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2023-04-05 18:57:37 +0100 |
commit | 78da22489b483988e198a8352893df9c6cf34032 (patch) | |
tree | 9711bb65e3b6f960ce077ba77c00cb5d914be372 /youtube_dl/options.py | |
parent | 557dbac173c30a51acd284b46f2d5460e539f51a (diff) |
[compat] Add and use `compat_open()` like Py3 `open()`
* resolves FIXME: ytdl-org/youtube-dl/commit/dfe5fa4
Diffstat (limited to 'youtube_dl/options.py')
-rw-r--r-- | youtube_dl/options.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/youtube_dl/options.py b/youtube_dl/options.py index f6d2b0898..7b059b51e 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -11,6 +11,7 @@ from .compat import ( compat_get_terminal_size, compat_getenv, compat_kwargs, + compat_open as open, compat_shlex_split, ) from .utils import ( @@ -41,14 +42,11 @@ def _hide_login_info(opts): def parseOpts(overrideArguments=None): def _readOptions(filename_bytes, default=[]): try: - optionf = open(filename_bytes) + optionf = open(filename_bytes, encoding=preferredencoding()) except IOError: return default # silently skip if file is not present try: - # FIXME: https://github.com/ytdl-org/youtube-dl/commit/dfe5fa49aed02cf36ba9f743b11b0903554b5e56 contents = optionf.read() - if sys.version_info < (3,): - contents = contents.decode(preferredencoding()) res = compat_shlex_split(contents, comments=True) finally: optionf.close() |