From 465f3c045b2cb7d757a8cbabc909c137901c9844 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sun, 2 Apr 2023 23:54:34 -0400 Subject: [PATCH] Prevented PostgreSQL's DatabaseCreation._execute_create_test_db() from hiding clause-less exceptions. Regression in 3cafb783f3f711c7413ba2b8d7c8ff750bd4d6e1. --- django/db/backends/postgresql/creation.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/django/db/backends/postgresql/creation.py b/django/db/backends/postgresql/creation.py index b445b89646..9b562cec18 100644 --- a/django/db/backends/postgresql/creation.py +++ b/django/db/backends/postgresql/creation.py @@ -45,8 +45,7 @@ class DatabaseCreation(BaseDatabaseCreation): 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)