提交 7d42c60d authored 作者: Frederic Bastien's avatar Frederic Bastien

Don't catch interup in try except.

上级 6a0b74bc
...@@ -152,7 +152,7 @@ class BadCLinkerOutput(DebugModeError): ...@@ -152,7 +152,7 @@ class BadCLinkerOutput(DebugModeError):
print >> ssio, numpy.isnan(self.val_py).sum(), print >> ssio, numpy.isnan(self.val_py).sum(),
# only if all succeeds to we add anything to sio # only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue() print >> sio, ssio.getvalue()
except: except Exception:
pass pass
try: try:
ssio = StringIO() ssio = StringIO()
...@@ -166,7 +166,7 @@ class BadCLinkerOutput(DebugModeError): ...@@ -166,7 +166,7 @@ class BadCLinkerOutput(DebugModeError):
print >> ssio, numpy.isnan(self.val_c).sum(), print >> ssio, numpy.isnan(self.val_c).sum(),
# only if all succeeds to we add anything to sio # only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue() print >> sio, ssio.getvalue()
except: except Exception:
pass pass
try: try:
ov=numpy.asarray(self.val_c) ov=numpy.asarray(self.val_c)
...@@ -184,7 +184,7 @@ class BadCLinkerOutput(DebugModeError): ...@@ -184,7 +184,7 @@ class BadCLinkerOutput(DebugModeError):
print >> ssio, " Std Rel Diff: ", numpy.std(reldiff) print >> ssio, " Std Rel Diff: ", numpy.std(reldiff)
# only if all succeeds to we add anything to sio # only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue() print >> sio, ssio.getvalue()
except: except Exception:
pass pass
return sio.getvalue() return sio.getvalue()
...@@ -246,7 +246,7 @@ class BadOptimization(DebugModeError): ...@@ -246,7 +246,7 @@ class BadOptimization(DebugModeError):
print >> ssio, self.old_r_val.strides print >> ssio, self.old_r_val.strides
# only if all succeeds to we add anything to sio # only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue() print >> sio, ssio.getvalue()
except: except Exception:
pass pass
str_old_r_val = str(self.old_r_val) str_old_r_val = str(self.old_r_val)
...@@ -263,7 +263,7 @@ class BadOptimization(DebugModeError): ...@@ -263,7 +263,7 @@ class BadOptimization(DebugModeError):
print >> ssio, self.new_r_val.strides print >> ssio, self.new_r_val.strides
# only if all succeeds to we add anything to sio # only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue() print >> sio, ssio.getvalue()
except: except Exception:
pass pass
str_new_r_val = str(self.new_r_val) str_new_r_val = str(self.new_r_val)
if len(str_new_r_val) > val_str_len_limit: if len(str_new_r_val) > val_str_len_limit:
...@@ -286,7 +286,7 @@ class BadOptimization(DebugModeError): ...@@ -286,7 +286,7 @@ class BadOptimization(DebugModeError):
print >> ssio, " Std Rel Diff: ", numpy.std(reldiff) print >> ssio, " Std Rel Diff: ", numpy.std(reldiff)
# only if all succeeds to we add anything to sio # only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue() print >> sio, ssio.getvalue()
except: except Exception:
pass pass
print >> sio, " Reason: ", str(self.reason) print >> sio, " Reason: ", str(self.reason)
...@@ -400,7 +400,7 @@ class InvalidValueError(DebugModeError): ...@@ -400,7 +400,7 @@ class InvalidValueError(DebugModeError):
v_min = v.min() v_min = v.min()
v_max = v.max() v_max = v.max()
v_isfinite = numpy.all(numpy.isfinite(v)) v_isfinite = numpy.all(numpy.isfinite(v))
except: except Exception:
pass pass
client_node = self.client_node client_node = self.client_node
hint = self.hint hint = self.hint
...@@ -687,7 +687,7 @@ def _check_strides_match(a, b, warn_err, op): ...@@ -687,7 +687,7 @@ def _check_strides_match(a, b, warn_err, op):
try: try:
strides_eq = a.strides == b.strides strides_eq = a.strides == b.strides
except: except Exception:
return # no strides return # no strides
if not strides_eq: if not strides_eq:
...@@ -1435,7 +1435,7 @@ class _Linker(gof.link.LocalLinker): ...@@ -1435,7 +1435,7 @@ class _Linker(gof.link.LocalLinker):
## First time, with None in output_storage ## First time, with None in output_storage
try: try:
thunk_c() thunk_c()
except: except Exception:
raise_with_op(node) raise_with_op(node)
for r in node.outputs: for r in node.outputs:
...@@ -1475,7 +1475,7 @@ class _Linker(gof.link.LocalLinker): ...@@ -1475,7 +1475,7 @@ class _Linker(gof.link.LocalLinker):
def thunk(): def thunk():
try: try:
thunk_c() thunk_c()
except: except Exception:
raise_with_op(node) raise_with_op(node)
_logger.debug( _logger.debug(
'%i - calling _check_preallocated_output ' '%i - calling _check_preallocated_output '
...@@ -1547,7 +1547,7 @@ class _Linker(gof.link.LocalLinker): ...@@ -1547,7 +1547,7 @@ class _Linker(gof.link.LocalLinker):
storage_map[r][0].itemset(dr_vals[r][0]) storage_map[r][0].itemset(dr_vals[r][0])
else: else:
storage_map[r][0] = dr_vals[r][0] storage_map[r][0] = dr_vals[r][0]
except: except Exception:
# Restore the initial state of storage_map # Restore the initial state of storage_map
for r in storage_map: for r in storage_map:
if r in original_storage_map_keys: if r in original_storage_map_keys:
......
...@@ -597,7 +597,7 @@ class Function(object): ...@@ -597,7 +597,7 @@ class Function(object):
t0_fn = time.time() t0_fn = time.time()
try: try:
self.fn() self.fn()
except: except Exception:
if hasattr(self.fn, 'position_of_error'): if hasattr(self.fn, 'position_of_error'):
# this is a new vm-provided function # this is a new vm-provided function
# the C VM needs this because the exception manipulation # the C VM needs this because the exception manipulation
...@@ -1107,7 +1107,7 @@ try: ...@@ -1107,7 +1107,7 @@ try:
# compatible with python 2.4, we implement pickling of slice # compatible with python 2.4, we implement pickling of slice
# ourself. # ourself.
cPickle.dumps(slice(0, 10, 100)) cPickle.dumps(slice(0, 10, 100))
except: except TypeError:
# This slice pickle implementation seam backward and forward compatible. # This slice pickle implementation seam backward and forward compatible.
def _pickle_slice(s): def _pickle_slice(s):
return (slice, (s.start, s.stop, s.step)) return (slice, (s.start, s.stop, s.step))
...@@ -1120,7 +1120,7 @@ def check_equal(x, y): ...@@ -1120,7 +1120,7 @@ def check_equal(x, y):
for checker in __checkers: for checker in __checkers:
try: try:
return checker(x, y) return checker(x, y)
except: except Exception:
continue continue
return x == y return x == y
#raise Exception('No checker for equality between %s and %s' % (x, y)) #raise Exception('No checker for equality between %s and %s' % (x, y))
......
...@@ -1120,7 +1120,7 @@ class Module(ComponentDict): ...@@ -1120,7 +1120,7 @@ class Module(ComponentDict):
self[k] = self.__wrapper__(recurse(v)) self[k] = self.__wrapper__(recurse(v))
try: try:
self[k] = self.__wrapper__(v) self[k] = self.__wrapper__(v)
except: except Exception:
if isinstance(v, Component): if isinstance(v, Component):
raise raise
else: else:
......
...@@ -143,7 +143,7 @@ def rebuild_collect_shared( outputs ...@@ -143,7 +143,7 @@ def rebuild_collect_shared( outputs
replace = [] replace = []
try: try:
replace_pairs = replace.items() replace_pairs = replace.items()
except: except Exception:
replace_pairs = replace replace_pairs = replace
for v_orig, v_repl in replace_pairs: for v_orig, v_repl in replace_pairs:
......
...@@ -472,7 +472,7 @@ class T_module(unittest.TestCase): ...@@ -472,7 +472,7 @@ class T_module(unittest.TestCase):
m = M.make() m = M.make()
try: try:
m.y = 77 #fail? m.y = 77 #fail?
except: except Exception:
pass pass
assert m.y == 40 assert m.y == 40
assert m.f(20) == 100 assert m.f(20) == 100
......
...@@ -461,7 +461,7 @@ def pydotprint(fct, outfile=None, ...@@ -461,7 +461,7 @@ def pydotprint(fct, outfile=None,
try: try:
import pydot as pd import pydot as pd
except: except ImportError:
print "failed to import pydot. Yous must install pydot for this function to work." print "failed to import pydot. Yous must install pydot for this function to work."
return return
......
...@@ -593,7 +593,7 @@ class unary_out_lookup(gof.utils.object2): ...@@ -593,7 +593,7 @@ class unary_out_lookup(gof.utils.object2):
types = types[0] types = types[0]
try: try:
rval = self.tbl[types] rval = self.tbl[types]
except: except Exception:
raise TypeError(types) raise TypeError(types)
if isinstance(types, (list, tuple)): if isinstance(types, (list, tuple)):
return rval return rval
......
...@@ -249,7 +249,7 @@ def isNaN_or_Inf_or_None(x): ...@@ -249,7 +249,7 @@ def isNaN_or_Inf_or_None(x):
isNaN = numpy.isnan(x) isNaN = numpy.isnan(x)
isInf = numpy.isinf(x) isInf = numpy.isinf(x)
isStr = isinstance(x, str) isStr = isinstance(x, str)
except: except Exception:
isNaN = False isNaN = False
isInf = False isInf = False
isStr = False isStr = False
...@@ -258,7 +258,7 @@ def isNaN_or_Inf_or_None(x): ...@@ -258,7 +258,7 @@ def isNaN_or_Inf_or_None(x):
val = get_constant_value(x) val = get_constant_value(x)
isInf = numpy.isinf(val) isInf = numpy.isinf(val)
isNaN = numpy.isnan(val) isNaN = numpy.isnan(val)
except: except Exception:
isNaN = False isNaN = False
isInf = False isInf = False
if isinstance(x, gof.Constant) and isinstance(x.data, str): if isinstance(x, gof.Constant) and isinstance(x.data, str):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论