Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tested exc_type instead of exc_value in __exit__.

exc_value might be None even though there's an exception, at least on
Python 2.6. Thanks Thomas Chaumeny for the report.

Fixed #21034.

Forward-port of a8624b2 from 1.6.x.
  • Loading branch information...
commit 4170b9f402efa7c3c065b02da32555fca2c631c0 1 parent 7b62324
Aymeric Augustin authored September 04, 2013

Showing 1 changed file with 7 additions and 7 deletions. Show diff stats Hide diff stats

  1. 14  django/db/transaction.py
14  django/db/transaction.py
@@ -311,7 +311,7 @@ def __exit__(self, exc_type, exc_value, traceback):
311 311
             connection.in_atomic_block = False
312 312
 
313 313
         try:
314  
-            if exc_value is None and not connection.needs_rollback:
  314
+            if exc_type is None and not connection.needs_rollback:
315 315
                 if connection.in_atomic_block:
316 316
                     # Release savepoint if there is one
317 317
                     if sid is not None:
@@ -411,7 +411,7 @@ def __enter__(self):
411 411
         self.entering(self.using)
412 412
 
413 413
     def __exit__(self, exc_type, exc_value, traceback):
414  
-        self.exiting(exc_value, self.using)
  414
+        self.exiting(exc_type, self.using)
415 415
 
416 416
     def __call__(self, func):
417 417
         @wraps(func)
@@ -454,7 +454,7 @@ def autocommit(using=None):
454 454
     def entering(using):
455 455
         enter_transaction_management(managed=False, using=using)
456 456
 
457  
-    def exiting(exc_value, using):
  457
+    def exiting(exc_type, using):
458 458
         leave_transaction_management(using=using)
459 459
 
460 460
     return _transaction_func(entering, exiting, using)
@@ -473,9 +473,9 @@ def commit_on_success(using=None):
473 473
     def entering(using):
474 474
         enter_transaction_management(using=using)
475 475
 
476  
-    def exiting(exc_value, using):
  476
+    def exiting(exc_type, using):
477 477
         try:
478  
-            if exc_value is not None:
  478
+            if exc_type is not None:
479 479
                 if is_dirty(using=using):
480 480
                     rollback(using=using)
481 481
             else:
@@ -504,7 +504,7 @@ def commit_manually(using=None):
504 504
     def entering(using):
505 505
         enter_transaction_management(using=using)
506 506
 
507  
-    def exiting(exc_value, using):
  507
+    def exiting(exc_type, using):
508 508
         leave_transaction_management(using=using)
509 509
 
510 510
     return _transaction_func(entering, exiting, using)
@@ -528,7 +528,7 @@ def commit_on_success_unless_managed(using=None, savepoint=False):
528 528
         def entering(using):
529 529
             pass
530 530
 
531  
-        def exiting(exc_value, using):
  531
+        def exiting(exc_type, using):
532 532
             set_dirty(using=using)
533 533
 
534 534
         return _transaction_func(entering, exiting, using)

0 notes on commit 4170b9f

Please sign in to comment.
Something went wrong with that request. Please try again.