Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #20028 -- Made atomic usable on callable instances.

Thanks Anssi for the report.
  • Loading branch information...
commit 885d98d24ac842708347c36644c61fc323c081ec 1 parent 4846e2b
@aaugustin aaugustin authored
Showing with 13 additions and 1 deletion.
  1. +2 −1  django/db/transaction.py
  2. +11 −0 tests/transactions/tests.py
View
3  django/db/transaction.py
@@ -17,6 +17,7 @@
from functools import wraps
from django.db import connections, DatabaseError, DEFAULT_DB_ALIAS
+from django.utils.decorators import available_attrs
class TransactionManagementError(Exception):
@@ -313,7 +314,7 @@ def __exit__(self, exc_type, exc_value, traceback):
def __call__(self, func):
- @wraps(func)
+ @wraps(func, assigned=available_attrs(func))
def inner(*args, **kwargs):
with self:
return func(*args, **kwargs)
View
11 tests/transactions/tests.py
@@ -300,6 +300,17 @@ def test_atomic_prevents_calling_transaction_management_methods(self):
transaction.leave_transaction_management()
+class AtomicMiscTests(TransactionTestCase):
+
+ def test_wrap_callable_instance(self):
+ # Regression test for #20028
+ class Callable(object):
+ def __call__(self):
+ pass
+ # Must not raise an exception
+ transaction.atomic(Callable())
+
+
class IgnorePendingDeprecationWarningsMixin(object):
def setUp(self):

0 comments on commit 885d98d

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