mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
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.
This commit is contained in:
parent
7b623247e8
commit
4170b9f402
@ -311,7 +311,7 @@ class Atomic(object):
|
|||||||
connection.in_atomic_block = False
|
connection.in_atomic_block = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if exc_value is None and not connection.needs_rollback:
|
if exc_type is None and not connection.needs_rollback:
|
||||||
if connection.in_atomic_block:
|
if connection.in_atomic_block:
|
||||||
# Release savepoint if there is one
|
# Release savepoint if there is one
|
||||||
if sid is not None:
|
if sid is not None:
|
||||||
@ -411,7 +411,7 @@ class Transaction(object):
|
|||||||
self.entering(self.using)
|
self.entering(self.using)
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
self.exiting(exc_value, self.using)
|
self.exiting(exc_type, self.using)
|
||||||
|
|
||||||
def __call__(self, func):
|
def __call__(self, func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
@ -454,7 +454,7 @@ def autocommit(using=None):
|
|||||||
def entering(using):
|
def entering(using):
|
||||||
enter_transaction_management(managed=False, using=using)
|
enter_transaction_management(managed=False, using=using)
|
||||||
|
|
||||||
def exiting(exc_value, using):
|
def exiting(exc_type, using):
|
||||||
leave_transaction_management(using=using)
|
leave_transaction_management(using=using)
|
||||||
|
|
||||||
return _transaction_func(entering, exiting, using)
|
return _transaction_func(entering, exiting, using)
|
||||||
@ -473,9 +473,9 @@ def commit_on_success(using=None):
|
|||||||
def entering(using):
|
def entering(using):
|
||||||
enter_transaction_management(using=using)
|
enter_transaction_management(using=using)
|
||||||
|
|
||||||
def exiting(exc_value, using):
|
def exiting(exc_type, using):
|
||||||
try:
|
try:
|
||||||
if exc_value is not None:
|
if exc_type is not None:
|
||||||
if is_dirty(using=using):
|
if is_dirty(using=using):
|
||||||
rollback(using=using)
|
rollback(using=using)
|
||||||
else:
|
else:
|
||||||
@ -504,7 +504,7 @@ def commit_manually(using=None):
|
|||||||
def entering(using):
|
def entering(using):
|
||||||
enter_transaction_management(using=using)
|
enter_transaction_management(using=using)
|
||||||
|
|
||||||
def exiting(exc_value, using):
|
def exiting(exc_type, using):
|
||||||
leave_transaction_management(using=using)
|
leave_transaction_management(using=using)
|
||||||
|
|
||||||
return _transaction_func(entering, exiting, using)
|
return _transaction_func(entering, exiting, using)
|
||||||
@ -528,7 +528,7 @@ def commit_on_success_unless_managed(using=None, savepoint=False):
|
|||||||
def entering(using):
|
def entering(using):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def exiting(exc_value, using):
|
def exiting(exc_type, using):
|
||||||
set_dirty(using=using)
|
set_dirty(using=using)
|
||||||
|
|
||||||
return _transaction_func(entering, exiting, using)
|
return _transaction_func(entering, exiting, using)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user