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>
This commit is contained in:
Petr Viktorin authored and Tomas Babej committed 2015-10-13 14:16:32 +02:00
1 parent 929c3d1265
commit 88ac1c1616
2 files changed
+4 -6

No files matched your search

+2 -1
View File
@@ -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
+2 -5
View File
@@ -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):