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 /ipatests/util.py | |
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>
Diffstat (limited to 'ipatests/util.py')
-rw-r--r-- | ipatests/util.py | 7 |
1 files changed, 2 insertions, 5 deletions
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): |