Issue #16261: Converted some bare except statements to except statements
with specified exception type. Original patch by Ramchandra Apte.
This commit is contained in:
parent
492f027793
commit
ba9ac5b5c4
|
@ -23,7 +23,7 @@ from types import MappingProxyType
|
|||
from weakref import WeakKeyDictionary
|
||||
try:
|
||||
from _thread import RLock
|
||||
except:
|
||||
except ImportError:
|
||||
class RLock:
|
||||
'Dummy reentrant lock for builds without threads'
|
||||
def __enter__(self): pass
|
||||
|
|
|
@ -135,7 +135,7 @@ def v4_int_to_packed(address):
|
|||
"""
|
||||
try:
|
||||
return address.to_bytes(4, 'big')
|
||||
except:
|
||||
except OverflowError:
|
||||
raise ValueError("Address negative or too large for IPv4")
|
||||
|
||||
|
||||
|
@ -151,7 +151,7 @@ def v6_int_to_packed(address):
|
|||
"""
|
||||
try:
|
||||
return address.to_bytes(16, 'big')
|
||||
except:
|
||||
except OverflowError:
|
||||
raise ValueError("Address negative or too large for IPv6")
|
||||
|
||||
|
||||
|
|
|
@ -465,7 +465,7 @@ try:
|
|||
for libname in ['uuid', 'c']:
|
||||
try:
|
||||
lib = ctypes.CDLL(ctypes.util.find_library(libname))
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if hasattr(lib, 'uuid_generate_random'):
|
||||
_uuid_generate_random = lib.uuid_generate_random
|
||||
|
@ -607,7 +607,7 @@ def uuid4():
|
|||
try:
|
||||
import os
|
||||
return UUID(bytes=os.urandom(16), version=4)
|
||||
except:
|
||||
except Exception:
|
||||
import random
|
||||
return UUID(int=random.getrandbits(128), version=4)
|
||||
|
||||
|
|
|
@ -572,7 +572,7 @@ def getTclTkVersion(configfile, versionline):
|
|||
"""
|
||||
try:
|
||||
f = open(configfile, "r")
|
||||
except:
|
||||
except OSError:
|
||||
fatal("Framework configuration file not found: %s" % configfile)
|
||||
|
||||
for l in f:
|
||||
|
@ -814,7 +814,7 @@ def downloadURL(url, fname):
|
|||
except:
|
||||
try:
|
||||
os.unlink(fname)
|
||||
except:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def verifyThirdPartyFile(url, checksum, fname):
|
||||
|
|
|
@ -261,7 +261,7 @@ class SheetParser:
|
|||
def end_int(self, text):
|
||||
try:
|
||||
self.value = int(text)
|
||||
except:
|
||||
except (TypeError, ValueError):
|
||||
self.value = None
|
||||
|
||||
end_long = end_int
|
||||
|
@ -269,13 +269,13 @@ class SheetParser:
|
|||
def end_double(self, text):
|
||||
try:
|
||||
self.value = float(text)
|
||||
except:
|
||||
except (TypeError, ValueError):
|
||||
self.value = None
|
||||
|
||||
def end_complex(self, text):
|
||||
try:
|
||||
self.value = complex(text)
|
||||
except:
|
||||
except (TypeError, ValueError):
|
||||
self.value = None
|
||||
|
||||
def end_string(self, text):
|
||||
|
@ -763,7 +763,7 @@ class SheetGUI:
|
|||
for cls in int, float, complex:
|
||||
try:
|
||||
value = cls(text)
|
||||
except:
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
else:
|
||||
cell = NumericCell(value)
|
||||
|
|
|
@ -25,7 +25,7 @@ def treat_file(filename, outfp):
|
|||
"""Append tags found in file named 'filename' to the open file 'outfp'"""
|
||||
try:
|
||||
fp = open(filename, 'r')
|
||||
except:
|
||||
except OSError:
|
||||
sys.stderr.write('Cannot open %s\n'%filename)
|
||||
return
|
||||
charno = 0
|
||||
|
|
|
@ -127,7 +127,7 @@ def hexrepr(t, precision=4):
|
|||
return 'None'
|
||||
try:
|
||||
len(t)
|
||||
except:
|
||||
except TypeError:
|
||||
return '0x%0*X' % (precision, t)
|
||||
try:
|
||||
return '(' + ', '.join(['0x%0*X' % (precision, item)
|
||||
|
|
Loading…
Reference in New Issue