Change in vdsm[master]: misc: Fix exception re-rasing in RollbackContext
nsoffer at redhat.com
nsoffer at redhat.com
Tue Dec 31 21:37:36 UTC 2013
Nir Soffer has posted comments on this change.
Change subject: misc: Fix exception re-rasing in RollbackContext
......................................................................
Patch Set 2: Code-Review+1
(3 comments)
Commit message need some cleanup, beautiful otherwise.
....................................................
Commit Message
Line 8:
Line 9: Former re-raising is faulty, as it doesn't take into consideration the
Line 10: possibility of a tuple being thrown. This can occur when accessing a
Line 11: dictionary with a missing key, for instance. In this case dictionary
Line 12: raises a tuple, i.e, {}['missingKey'], raises the tuple
"The dictionary raises a tupple" is not correct. A more correct description is:
When a KeyError is raised inside the rollback context, the arguments we get in __exit__ are KeyError, ("missingkey",), traceback.
Line 13: ('missingKey',). In the former implementation, the variable
Line 14: firstException is assinged with exc_value, which, in the above case,
Line 15: is a tuple. When it's re-raised
Line 16: (raise firstException, None, traceback), the type of the exception is
Line 14: firstException is assinged with exc_value, which, in the above case,
Line 15: is a tuple. When it's re-raised
Line 16: (raise firstException, None, traceback), the type of the exception is
Line 17: the class of the original exc_value, which is the tuple
Line 18: ('missingKey',), as is (implicitly) exc_value.
Looks like a empty line between these paragraphs is missing.
Line 19: This scenario is not supported by the raise statement, which is not
Line 20: supposed to receive a tuple as the first expression. This is then
Line 21: being interpreted as a string by python and we receive the following:
Line 22: "TypeError: exceptions must be old-style classes or derived from
....................................................
File tests/miscTests.py
Line 1155: self.fail("Wrong exception was raised")
Line 1156:
Line 1157: self.fail("Exception was not raised")
Line 1158:
Line 1159:
Nice test!
Line 1160: class FindCallerTests(TestCaseBase):
Line 1161: def _assertFindCaller(self, callback):
Line 1162: frame = inspect.currentframe()
Line 1163: code = frame.f_code
--
To view, visit http://gerrit.ovirt.org/22860
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I0052717e2307ad6fec2225b3ad5f438c5a60e1c6
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vered Volansky <vvolansk at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list