mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-03 00:42:51 +08:00
Catch all errors when trying to run external commands
Trying to run a non-installed command (such as avprobe) through Popen may throw other errors than `OSError`. For example, a `ValueError` may happen on macOS 10.12.6: ``` $ ./youtube-dl -U -v [debug] System config: [] [debug] User config: [] [debug] Custom config: [] [debug] Command-line args: [u'-U', u'-v'] [debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8 [debug] youtube-dl version 2018.06.25 [debug] Python version 2.7.10 (CPython) - Darwin-16.7.0-x86_64-i386-64bit Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "./youtube-dl/__main__.py", line 19, in <module> File "./youtube-dl/youtube_dl/__init__.py", line 472, in main File "./youtube-dl/youtube_dl/__init__.py", line 439, in _real_main File "./youtube-dl/youtube_dl/YoutubeDL.py", line 417, in __init__ File "./youtube-dl/youtube_dl/YoutubeDL.py", line 2260, in print_debug_header File "./youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 76, in get_versions File "./youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 60, in __init__ File "./youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 117, in _determine_executables File "./youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 117, in <genexpr> File "./youtube-dl/youtube_dl/utils.py", line 1962, in get_exe_version File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1334, in _execute_child child_exception = pickle.loads(data) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1382, in loads return Unpickler(file).load() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 858, in load dispatch[key](self) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 966, in load_string raise ValueError, "insecure string pickle" ValueError: insecure string pickle ``` Catching all errors instead of only `OSError` should be safer.
This commit is contained in:
parent
c3bcd206eb
commit
bdbf6155eb
2
youtube_dl/utils.py
Normal file → Executable file
2
youtube_dl/utils.py
Normal file → Executable file
@ -1960,7 +1960,7 @@ def get_exe_version(exe, args=['--version'],
|
|||||||
[encodeArgument(exe)] + args,
|
[encodeArgument(exe)] + args,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
|
||||||
except OSError:
|
except:
|
||||||
return False
|
return False
|
||||||
if isinstance(out, bytes): # Python 2.x
|
if isinstance(out, bytes): # Python 2.x
|
||||||
out = out.decode('ascii', 'ignore')
|
out = out.decode('ascii', 'ignore')
|
||||||
|
Loading…
Reference in New Issue
Block a user