diff options
| author | Xavier Ordoquy | 2012-11-22 00:20:49 +0100 | 
|---|---|---|
| committer | Xavier Ordoquy | 2012-11-22 00:20:49 +0100 | 
| commit | b3698acb6c0b9eaa04189599e27014c788a75adc (patch) | |
| tree | 25de3a90ca99b6de980ce0c4031ffb512d9f9c00 /rest_framework/compat.py | |
| parent | ab3c47297481b7a4ff66027618f9c05bf02a2204 (diff) | |
| download | django-rest-framework-b3698acb6c0b9eaa04189599e27014c788a75adc.tar.bz2 | |
First passing test under p3k \o/
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 16 | 
1 files changed, 10 insertions, 6 deletions
| diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 09b76368..dcc8aaa6 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 @@ -16,7 +19,7 @@ except:  try:      import cStringIO 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." | 
