aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/options.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-04-12 03:57:56 +0600
committerSergey M․ <dstftw@gmail.com>2015-04-12 03:57:56 +0600
commitb04b94da5fbe944e2a9d2946ab8b3acb212f9f70 (patch)
tree1af027e6f585f4de942453eb19b1ac66f7a50bdc /youtube_dl/options.py
parent9933857f679392a2e3b2a8d53f89b61ca8e13a00 (diff)
downloadyoutube-dl-b04b94da5fbe944e2a9d2946ab8b3acb212f9f70.tar.xz
[options] Fix file based configurations for python 2 (Closes #5401)
Diffstat (limited to 'youtube_dl/options.py')
-rw-r--r--youtube_dl/options.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/youtube_dl/options.py b/youtube_dl/options.py
index 5720fb424..11603f60d 100644
--- a/youtube_dl/options.py
+++ b/youtube_dl/options.py
@@ -794,21 +794,22 @@ def parseOpts(overrideArguments=None):
if opts.verbose:
write_string('[debug] Override config: ' + repr(overrideArguments) + '\n')
else:
- command_line_conf = sys.argv[1:]
- # Workaround for Python 2.x, where argv is a byte list
- if sys.version_info < (3,):
- command_line_conf = [
- a.decode(preferredencoding(), 'replace') for a in command_line_conf]
+ def compat_conf(conf):
+ if sys.version_info < (3,):
+ return [a.decode(preferredencoding(), 'replace') for a in conf]
+ return conf
+
+ command_line_conf = compat_conf(sys.argv[1:])
if '--ignore-config' in command_line_conf:
system_conf = []
user_conf = []
else:
- system_conf = _readOptions('/etc/youtube-dl.conf')
+ system_conf = compat_conf(_readOptions('/etc/youtube-dl.conf'))
if '--ignore-config' in system_conf:
user_conf = []
else:
- user_conf = _readUserConf()
+ user_conf = compat_conf(_readUserConf())
argv = system_conf + user_conf + command_line_conf
opts, args = parser.parse_args(argv)