Merge lp://staging/~cjwatson/storm/refactor-exception-wrapping into lp://staging/storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 509
Proposed branch: lp://staging/~cjwatson/storm/refactor-exception-wrapping
Merge into: lp://staging/storm
Diff against target: 423 lines (+228/-31)
6 files modified
NEWS (+4/-0)
storm/database.py (+132/-1)
storm/databases/postgres.py (+28/-7)
storm/databases/sqlite.py (+15/-9)
storm/exceptions.py (+46/-14)
tests/database.py (+3/-0)
To merge this branch: bzr merge lp://staging/~cjwatson/storm/refactor-exception-wrapping
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
Review via email: mp+369319@code.staging.launchpad.net

Commit message

Wrap DB-API exceptions rather than injecting virtual base classes.

Description of the change

Re-raise DB-API exceptions wrapped in exception types that inherit from both StormError and the appropriate DB-API exception type, rather than injecting virtual base classes. This preserves existing exception handling in applications while also being a viable approach in Python 3.

Once I managed to get the right wrappers in place, this ended up being surprisingly simple, which makes me feel good about it (my first draft had many more explicit calls to wrap_exceptions and so felt much more fragile). The main difficulty was in creating just the right wrapper exception types to maintain API compatibility without making the code painfully repetitive, and I finally got that to fall into place today.

I'm running the full Launchpad test suite over this at the moment, though it looks clean so far and I've already found and fixed some problems via some of its most Storm-sensitive tests.

To post a comment you must log in.
509. By Colin Watson

Make wrapper exceptions look slightly more like the DB-API originals.

510. By Colin Watson

Improve comment.

Revision history for this message
Colin Watson (cjwatson) wrote :

I've done a full successful Launchpad test run with this patch. The only change I had to make to Launchpad was to adjust LaunchpadDatabase.__init__, which is just because it's subclassing Postgres while (for unrelated reasons) not running the superclass constructor, so as a consequence it has to keep up with changes to the superclass constructor, which I think is fine.

Revision history for this message
Simon Poirier (simpoir) wrote :

+1
I ran the full landscape test suite against this without any apparent regression.

review: Approve
511. By Colin Watson

Use superclass __setattr__ rather than changing __dict__ directly.

512. By Colin Watson

Use more neutral language.

Revision history for this message
Colin Watson (cjwatson) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: