Merge lp:~cjwatson/storm/psycopg2-missing-diag into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 520
Proposed branch: lp:~cjwatson/storm/psycopg2-missing-diag
Merge into: lp:storm
Diff against target: 16 lines (+5/-1)
1 file modified
storm/databases/postgres.py (+5/-1)
To merge this branch: bzr merge lp:~cjwatson/storm/psycopg2-missing-diag
Reviewer Review Type Date Requested Status
Kristian Glass (community) Approve
Storm Developers Pending
Review via email: mp+371169@code.launchpad.net

Commit message

Fix error wrapping with psycopg2 < 2.5.

Description of the change

psycopg2.Error.diag was only added in 2.5, so don't try to wrap it if it doesn't exist.

Bug introduced in https://code.launchpad.net/~cjwatson/storm/refactor-exception-wrapping/+merge/369319.

To post a comment you must log in.
Revision history for this message
Kristian Glass (doismellburning) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storm/databases/postgres.py'
2--- storm/databases/postgres.py 2019-06-25 21:33:26 +0000
3+++ storm/databases/postgres.py 2019-08-11 14:39:26 +0000
4@@ -398,7 +398,11 @@
5 "'autocommit', 'serializable', 'read-committed'" %
6 (isolation,))
7
8- _psycopg_error_attributes = ("pgerror", "pgcode", "cursor", "diag")
9+ _psycopg_error_attributes = ["pgerror", "pgcode", "cursor"]
10+ # Added in psycopg2 2.5.
11+ if hasattr(psycopg2.Error, "diag"):
12+ _psycopg_error_attributes.append("diag")
13+ _psycopg_error_attributes = tuple(_psycopg_error_attributes)
14
15 def _make_combined_exception_type(self, wrapper_type, dbapi_type):
16 combined_type = super(Postgres, self)._make_combined_exception_type(

Subscribers

People subscribed via source and target branches

to status/vote changes: