diff --git a/django/db/backends/mysql/creation.py b/django/db/backends/mysql/creation.py index e51de0faa1..c9330819e5 100644 --- a/django/db/backends/mysql/creation.py +++ b/django/db/backends/mysql/creation.py @@ -26,7 +26,7 @@ class DatabaseCreation(BaseDatabaseCreation): self.log('Got an error creating the test database: %s' % e) sys.exit(2) else: - raise e + raise def _clone_test_db(self, suffix, verbosity, keepdb=False): source_database_name = self.connection.settings_dict['NAME'] diff --git a/django/db/backends/postgresql/creation.py b/django/db/backends/postgresql/creation.py index 09af818b1e..0cb26a4341 100644 --- a/django/db/backends/postgresql/creation.py +++ b/django/db/backends/postgresql/creation.py @@ -48,7 +48,7 @@ class DatabaseCreation(BaseDatabaseCreation): elif not keepdb: # If the database should be kept, ignore "database already # exists". - raise e + raise def _clone_test_db(self, suffix, verbosity, keepdb=False): # CREATE DATABASE ... WITH TEMPLATE ... requires closing connections diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py index 6be8048299..09a58d1e24 100644 --- a/django/db/migrations/loader.py +++ b/django/db/migrations/loader.py @@ -269,7 +269,7 @@ class MigrationLoader: ), exc.node ) from exc - raise exc + raise self.graph.ensure_not_cyclic() def check_consistent_history(self, connection): diff --git a/django/db/models/query.py b/django/db/models/query.py index f8be008a62..005fde44c6 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -607,13 +607,13 @@ class QuerySet: params = dict(resolve_callables(params)) obj = self.create(**params) return obj, True - except IntegrityError as e: + except IntegrityError: try: qs = self.select_for_update() if lock else self return qs.get(**lookup), False except self.model.DoesNotExist: pass - raise e + raise def _extract_model_params(self, defaults, **kwargs): """