Issue #16261: Converted some bare except statements to except statements

with specified exception type.  Original patch by Ramchandra Apte.
This commit is contained in:
Serhiy Storchaka 2015-05-20 10:33:40 +03:00
parent 492f027793
commit ba9ac5b5c4
7 changed files with 13 additions and 13 deletions

View file

@ -23,7 +23,7 @@
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

View file

@ -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")

View file

@ -465,7 +465,7 @@ def _netbios_getnode():
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)

View file

@ -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):

View file

@ -261,7 +261,7 @@ def start_value(self, attrs):
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 @@ def end_int(self, text):
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 @@ def change_cell(self):
for cls in int, float, complex:
try:
value = cls(text)
except:
except (TypeError, ValueError):
continue
else:
cell = NumericCell(value)

View file

@ -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

View file

@ -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)