mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
Don't use bare 'except:'
They catch any exception, including KeyboardInterrupt, we don't want to catch it.
This commit is contained in:
parent
af14000215
commit
70a1165b32
|
@ -28,7 +28,7 @@
|
|||
if METHOD == 'EURISTIC':
|
||||
try:
|
||||
webpage = compat_urllib_request.urlopen(test['url'], timeout=10).read()
|
||||
except:
|
||||
except Exception:
|
||||
print('\nFail: {0}'.format(test['name']))
|
||||
continue
|
||||
|
||||
|
|
|
@ -1701,10 +1701,10 @@ def print_debug_header(self):
|
|||
out = out.decode().strip()
|
||||
if re.match('[0-9a-f]+', out):
|
||||
self._write_string('[debug] Git HEAD: ' + out + '\n')
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
sys.exc_clear()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._write_string('[debug] Python version %s - %s\n' % (
|
||||
platform.python_version(), platform_name()))
|
||||
|
|
|
@ -389,7 +389,7 @@ def compat_get_terminal_size():
|
|||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
out, err = sp.communicate()
|
||||
lines, columns = map(int, out.split())
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return _terminal_size(columns, lines)
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ def try_utime(self, filename, last_modified_hdr):
|
|||
return
|
||||
try:
|
||||
os.utime(filename, (time.time(), filetime))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return filetime
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ def _real_extract(self, url):
|
|||
webpage, 'JSON parameters')
|
||||
try:
|
||||
params = json.loads(json_params)
|
||||
except:
|
||||
except ValueError:
|
||||
raise ExtractorError('Invalid JSON')
|
||||
|
||||
self.report_extraction(video_id)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import io
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
|
@ -269,19 +268,17 @@ def run(self, information):
|
|||
else:
|
||||
self._downloader.to_screen('[' + self.basename + '] Destination: ' + new_path)
|
||||
self.run_ffmpeg(path, new_path, acodec, more_opts)
|
||||
except:
|
||||
etype, e, tb = sys.exc_info()
|
||||
if isinstance(e, AudioConversionError):
|
||||
msg = 'audio conversion failed: ' + e.msg
|
||||
else:
|
||||
msg = 'error running ' + self.basename
|
||||
raise PostProcessingError(msg)
|
||||
except AudioConversionError as e:
|
||||
raise PostProcessingError(
|
||||
'audio conversion failed: ' + e.msg)
|
||||
except Exception:
|
||||
raise PostProcessingError('error running ' + self.basename)
|
||||
|
||||
# Try to update the date time for extracted audio file.
|
||||
if information.get('filetime') is not None:
|
||||
try:
|
||||
os.utime(encodeFilename(new_path), (time.time(), information['filetime']))
|
||||
except:
|
||||
except Exception:
|
||||
self._downloader.report_warning('Cannot update utime of audio file')
|
||||
|
||||
information['filepath'] = new_path
|
||||
|
|
|
@ -65,7 +65,7 @@ def update_self(to_screen, verbose):
|
|||
# Check if there is a new version
|
||||
try:
|
||||
newversion = opener.open(VERSION_URL).read().decode('utf-8').strip()
|
||||
except:
|
||||
except Exception:
|
||||
if verbose:
|
||||
to_screen(compat_str(traceback.format_exc()))
|
||||
to_screen('ERROR: can\'t find the current version. Please try again later.')
|
||||
|
@ -78,7 +78,7 @@ def update_self(to_screen, verbose):
|
|||
try:
|
||||
versions_info = opener.open(JSON_URL).read().decode('utf-8')
|
||||
versions_info = json.loads(versions_info)
|
||||
except:
|
||||
except Exception:
|
||||
if verbose:
|
||||
to_screen(compat_str(traceback.format_exc()))
|
||||
to_screen('ERROR: can\'t obtain versions info. Please try again later.')
|
||||
|
|
|
@ -75,7 +75,7 @@ def preferredencoding():
|
|||
try:
|
||||
pref = locale.getpreferredencoding()
|
||||
'TEST'.encode(pref)
|
||||
except:
|
||||
except Exception:
|
||||
pref = 'UTF-8'
|
||||
|
||||
return pref
|
||||
|
@ -127,7 +127,7 @@ def write_json_file(obj, fn):
|
|||
except OSError:
|
||||
pass
|
||||
os.rename(tf.name, fn)
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
os.remove(tf.name)
|
||||
except OSError:
|
||||
|
|
Loading…
Reference in a new issue