- marked as blocker
mapper.py raises wrong exception
I made the following fix to help with debugging my own code, and I figured I might as well submit it. When Mapper.init catches an exception raised in calling init on the mapped class, it calls session.expunge(self), but fails to catch further exceptions that might be raised in this call. (In my case, the mapped instance was never attached to the session before an exception was raised in init -- maybe because it inherited from another mapped class and the exception originated in the superclass's constructor? -- leading session.expunge to raise InvalidRequestError: Instance 'XXX' not attached to this Session). My patch just catches exceptions like this and re-raises the original exception as one would expect.
Comments (5)
-
repo owner -
repo owner - assigned issue to
need a short unit test added to
test/orm/mapper.py
MapperTest
when this fix is committed. -
- changed status to resolved
-
This works too well- real internal bugs can hide from unit tests (like changeset:2763). Need some additional tests or tweaks to bring these to light when they happen.
-
repo owner - changed status to resolved
ive changed it so that session.expunge() exceptions are converted to warnings, also the rethrow is of the anonymous variety so that the original stack trace is maintained. changeset:2825 changeset:2826
- Log in to comment
thats a nasty issue...its important, thanks.