Skip to content

Commit c7fb93c

Browse files
committed
COMP: PEP 8: E722 do not use bare 'except'
1 parent 5b5d79c commit c7fb93c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Wrapping/Generators/Python/itkTemplate.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ def __getitem__(self, parameters):
340340

341341
try:
342342
return self.__template__[tuple(cleanParameters)]
343-
except:
343+
except KeyError:
344344
self._LoadModules()
345345
try:
346346
return self.__template__[tuple(cleanParameters)]
347-
except:
347+
except KeyError:
348348
raise TemplateTypeError(self, tuple(cleanParameters))
349349

350350
def __repr__(self):
@@ -793,12 +793,15 @@ def progress():
793793
callback(name, self.GetProgress())
794794

795795
self.AddObserver(itk.ProgressEvent(), progress)
796-
except:
797-
# it seems that something goes wrong...
796+
except AttributeError:
798797
# as this feature is designed for prototyping, it's not really a
799798
# problem if an object doesn't have progress reporter, so adding
800799
# reporter can silently fail
801800
pass
801+
except Exception:
802+
# it seems that something else has gone wrong...
803+
# silently fail to maintain backward compatibility
804+
pass
802805

803806
if itkConfig.NotInPlace and "SetInPlace" in dir(self):
804807
self.SetInPlace(False)

0 commit comments

Comments
 (0)