diff options
author | Petr Viktorin <pviktori@redhat.com> | 2015-09-18 17:26:07 +0200 |
---|---|---|
committer | Tomas Babej <tbabej@redhat.com> | 2015-10-13 14:16:32 +0200 |
commit | 88ac1c1616d2dc44fa909a0da49be413660166e6 (patch) | |
tree | 07ae5c8dc21845be764a98e48116d72cd439d871 | |
parent | 929c3d1265dcb7af375d433a7e0b44193e19ed2f (diff) | |
download | freeipa-88ac1c1616d2dc44fa909a0da49be413660166e6.tar.gz freeipa-88ac1c1616d2dc44fa909a0da49be413660166e6.tar.xz freeipa-88ac1c1616d2dc44fa909a0da49be413660166e6.zip |
Rename caught exception for use outside the except: block.
In Python 3, the variable with the currently handled exception is unset
at the end of the except block. (This is done to break reference
cycles, since exception instances now carry tracebacks, which contain
all locals.)
Fix this in baseldap's error handler.
Use a simpler structure for the ipatests.raises utility that only uses the
exception inside the except block.
Reviewed-By: Tomas Babej <tbabej@redhat.com>
-rw-r--r-- | ipalib/plugins/baseldap.py | 3 | ||||
-rw-r--r-- | ipatests/util.py | 7 |
2 files changed, 4 insertions, 6 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 847db9c21..1c822ecda 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -1148,7 +1148,8 @@ last, after all sets and adds."""), while True: try: return func(*call_args, **call_kwargs) - except errors.ExecutionError as e: + except errors.ExecutionError as exc: + e = exc if not callbacks: raise # call exc_callback in the next loop diff --git a/ipatests/util.py b/ipatests/util.py index 85b5dbc5e..c6566c930 100644 --- a/ipatests/util.py +++ b/ipatests/util.py @@ -370,14 +370,11 @@ def raises(exception, callback, *args, **kw): Tests that the expected exception is raised; raises ExceptionNotRaised if test fails. """ - raised = False try: callback(*args, **kw) except exception as e: - raised = True - if not raised: - raise ExceptionNotRaised(exception) - return e + return e + raise ExceptionNotRaised(exception) def getitem(obj, key): |