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
2015-09-18 17:26:07 +02:00
committed by Tomas Babej
parent 929c3d1265
commit 88ac1c1616
2 changed files with 4 additions and 6 deletions

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):