From 844089de076e357f6b62d75099a5bd21bf7c94e5 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 16 Aug 2008 15:58:30 +0000 Subject: [PATCH] Fixed #8315 -- If an exception is raised whilst trying to rollback a transaction (after another exception in the code), make sure the original exception is reported, rather than the rollback-generated one. The latter is almost certainly a consequence of the former. Patch from Karen Tracey. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8411 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django/db/__init__.py b/django/db/__init__.py index ffcd64b35b7..58d66b02c88 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -53,5 +53,8 @@ signals.request_started.connect(reset_queries) # when a Django request has an exception. def _rollback_on_exception(**kwargs): from django.db import transaction - transaction.rollback_unless_managed() + try: + transaction.rollback_unless_managed() + except DatabaseError: + pass signals.got_request_exception.connect(_rollback_on_exception)