diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-12 10:52:16 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-12 10:52:16 +0100 |
| commit | 885d98d24ac842708347c36644c61fc323c081ec (patch) | |
| tree | 88d7bbd22470aff83c7ff07426a891625472a333 | |
| parent | 4846e2b744f4a376f9c364a90c5a852312a0ceaf (diff) | |
Fixed #20028 -- Made atomic usable on callable instances.
Thanks Anssi for the report.
| -rw-r--r-- | django/db/transaction.py | 3 | ||||
| -rw-r--r-- | tests/transactions/tests.py | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/django/db/transaction.py b/django/db/transaction.py index 3a4c3f2b8d..1ff1a8437e 100644 --- a/django/db/transaction.py +++ b/django/db/transaction.py @@ -17,6 +17,7 @@ import warnings 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 @@ class Atomic(object): def __call__(self, func): - @wraps(func) + @wraps(func, assigned=available_attrs(func)) def inner(*args, **kwargs): with self: return func(*args, **kwargs) diff --git a/tests/transactions/tests.py b/tests/transactions/tests.py index e5a608e583..e53a320481 100644 --- a/tests/transactions/tests.py +++ b/tests/transactions/tests.py @@ -300,6 +300,17 @@ class AtomicErrorsTests(TransactionTestCase): 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): |
