with specified exception type. Original patch by Ramchandra Apte.
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
"""
try:
return address.to_bytes(4, 'big')
- except:
+ except OverflowError:
raise ValueError("Address negative or too large for IPv4")
"""
try:
return address.to_bytes(16, 'big')
- except:
+ except OverflowError:
raise ValueError("Address negative or too large for IPv6")
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
try:
import os
return UUID(bytes=os.urandom(16), version=4)
- except:
+ except Exception:
import random
return UUID(int=random.getrandbits(128), version=4)
"""
try:
f = open(configfile, "r")
- except:
+ except OSError:
fatal("Framework configuration file not found: %s" % configfile)
for l in f:
except:
try:
os.unlink(fname)
- except:
+ except OSError:
pass
def verifyThirdPartyFile(url, checksum, fname):
def end_int(self, text):
try:
self.value = int(text)
- except:
+ except (TypeError, ValueError):
self.value = None
end_long = end_int
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):
for cls in int, float, complex:
try:
value = cls(text)
- except:
+ except (TypeError, ValueError):
continue
else:
cell = NumericCell(value)
"""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
return 'None'
try:
len(t)
- except:
+ except TypeError:
return '0x%0*X' % (precision, t)
try:
return '(' + ', '.join(['0x%0*X' % (precision, item)