Skip to content

Commit

Permalink
Simplify the catch block in execute_actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Sep 28, 2018
1 parent 43ff10a commit 2b68d74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
26 changes: 9 additions & 17 deletions src/zope/configuration/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,23 +764,15 @@ def execute_actions(self, clear=True, testing=False):
info = action['info']
try:
callable(*args, **kw)
except BaseException as ex:
try:
if isinstance(ex, ConfigurationError):
ex.append_details(info)
raise
if isinstance(ex, pass_through_exceptions):
raise
if not isinstance(ex, Exception):
# BaseException
raise

# Wrap it up and raise.
reraise(ConfigurationExecutionError(info, ex),
None, sys.exc_info()[2])
finally:
del ex

except ConfigurationError as ex:
ex.append_details(info)
raise
except pass_through_exceptions:
raise
except Exception:
# Wrap it up and raise.
reraise(ConfigurationExecutionError(info, sys.exc_info()[1]),
None, sys.exc_info()[2])
finally:
if clear:
del self.actions[:]
Expand Down
7 changes: 3 additions & 4 deletions src/zope/configuration/xmlconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,9 @@ def _handle_exception(self, ex, info):
if isinstance(ex, ConfigurationError):
ex.append_details(repr(info))
raise
else:
exc = ZopeXMLConfigurationError(info, ex)
reraise(exc,
None, sys.exc_info()[2])

exc = ZopeXMLConfigurationError(info, ex)
reraise(exc, None, sys.exc_info()[2])

def startElementNS(self, name, qname, attrs):
if self.ignore_depth:
Expand Down

0 comments on commit 2b68d74

Please sign in to comment.