Permalink
Browse files

Refs #23919 -- Removed usage of django.utils.decorators.ContextDecora…

…tor.
  • Loading branch information...
ChillarAnand authored and timgraham committed Jan 19, 2017
1 parent 4c5ed3e commit 41e0033caf1267edda2b780ae50a3881c3de94ef
Showing with 6 additions and 23 deletions.
  1. +2 −1 django/db/transaction.py
  2. +2 −20 django/utils/decorators.py
  3. +1 −1 django/utils/timezone.py
  4. +1 −1 django/utils/translation/__init__.py
View
@@ -1,7 +1,8 @@
+from contextlib import ContextDecorator
+
from django.db import (
DEFAULT_DB_ALIAS, DatabaseError, Error, ProgrammingError, connections,
)
-from django.utils.decorators import ContextDecorator
class TransactionManagementError(ProgrammingError):
View
@@ -1,10 +1,7 @@
"Functions that help with dynamically creating decorators for views."
-try:
- from contextlib import ContextDecorator
-except ImportError:
- ContextDecorator = None
-
+# For backwards compatibility in Django 2.0.
+from contextlib import ContextDecorator # noqa
from functools import WRAPPER_ASSIGNMENTS, update_wrapper, wraps
@@ -166,21 +163,6 @@ def callback(response):
return _make_decorator
-if ContextDecorator is None:
- # ContextDecorator was introduced in Python 3.2
- # See https://docs.python.org/3/library/contextlib.html#contextlib.ContextDecorator
- class ContextDecorator:
- """
- A base class that enables a context manager to also be used as a decorator.
- """
- def __call__(self, func):
- @wraps(func, assigned=available_attrs(func))
- def inner(*args, **kwargs):
- with self:
- return func(*args, **kwargs)
- return inner
-
-
class classproperty:
def __init__(self, method=None):
self.fget = method
View
@@ -3,13 +3,13 @@
"""
import functools
+from contextlib import ContextDecorator
from datetime import datetime, timedelta, tzinfo
from threading import local
import pytz
from django.conf import settings
-from django.utils.decorators import ContextDecorator
__all__ = [
'utc', 'get_fixed_timezone',
@@ -3,8 +3,8 @@
"""
import re
import warnings
+from contextlib import ContextDecorator
-from django.utils.decorators import ContextDecorator
from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.encoding import force_text
from django.utils.functional import lazy

0 comments on commit 41e0033

Please sign in to comment.