diff options
| author | Xavier Ordoquy | 2012-11-22 07:48:41 +0100 |
|---|---|---|
| committer | Xavier Ordoquy | 2012-11-22 07:48:41 +0100 |
| commit | be003145ca120708db51db4e85f6088bde8dce1c (patch) | |
| tree | 9df0e343b9adc196ddd7e5fbc1b93e4c339260b2 /rest_framework/compat.py | |
| parent | 91190487b747f0c9c09ecd5678f719bb2e745d27 (diff) | |
| parent | 606c20f012c5a1fdcfd661eb280bab22b94afcf5 (diff) | |
| download | django-rest-framework-be003145ca120708db51db4e85f6088bde8dce1c.tar.bz2 | |
Merge branch 'p3k' of github.com:linovia/django-rest-framework into p3k
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 09b76368..8c7617c1 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -3,6 +3,9 @@ The `compat` module provides support for backwards compatibility with older versions of django/python, and compatibility wrappers around optional packages. """ # flake8: noqa +from __future__ import unicode_literals +import six + import django # django-filter is optional @@ -14,9 +17,9 @@ except: # cStringIO only if it's available, otherwise StringIO try: - import cStringIO as StringIO + import cStringIO.StringIO as StringIO except ImportError: - import StringIO + from six import StringIO def get_concrete_model(model_cls): @@ -38,7 +41,7 @@ else: try: from django.contrib.auth.models import User except ImportError: - raise ImportError(u"User model is not to be found.") + raise ImportError("User model is not to be found.") # First implementation of Django class-based views did not include head method @@ -59,11 +62,11 @@ else: # sanitize keyword arguments for key in initkwargs: if key in cls.http_method_names: - raise TypeError(u"You tried to pass in the %s method name as a " - u"keyword argument to %s(). Don't do that." + raise TypeError("You tried to pass in the %s method name as a " + "keyword argument to %s(). Don't do that." % (key, cls.__name__)) if not hasattr(cls, key): - raise TypeError(u"%s() received an invalid keyword %r" % ( + raise TypeError("%s() received an invalid keyword %r" % ( cls.__name__, key)) def view(request, *args, **kwargs): @@ -130,7 +133,8 @@ else: randrange = random.SystemRandom().randrange else: randrange = random.randrange - _MAX_CSRF_KEY = 18446744073709551616L # 2 << 63 + + _MAX_CSRF_KEY = 18446744073709551616 # 2 << 63 REASON_NO_REFERER = "Referer checking failed - no Referer." REASON_BAD_REFERER = "Referer checking failed - %s does not match %s." |
