Skip to content

Commit

Permalink
[4.2.x] Prevented PostgreSQL's DatabaseCreation._execute_create_test_…
Browse files Browse the repository at this point in the history
…db() from hiding clause-less exceptions.

Regression in 3cafb78.
Backport of 465f3c0 from main
  • Loading branch information
timgraham authored and felixxm committed Apr 3, 2023
1 parent 48d5889 commit 837e68a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions django/db/backends/postgresql/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def _execute_create_test_db(self, cursor, parameters, keepdb=False):
return
super()._execute_create_test_db(cursor, parameters, keepdb)
except Exception as e:
cause = e.__cause__
if cause and not isinstance(cause, errors.DuplicateDatabase):
if not isinstance(e.__cause__, errors.DuplicateDatabase):
# All errors except "database already exists" cancel tests.
self.log("Got an error creating the test database: %s" % e)
sys.exit(2)
Expand Down

0 comments on commit 837e68a

Please sign in to comment.