Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


[py3] fixed __proxy__.decode doesn't exists #281

wants to merge 1 commit into from

2 participants

Rémy HUBSCHER Aymeric Augustin

fixed proxy.decode doesn't exists on django/contrib/auth/

Aymeric Augustin aaugustin closed this
Aymeric Augustin

GitHub seems to have lost my comment :( Here is it again.

I'd prefer to fix the root cause rather than this specific symptom, as explained in this ticket:
The conditional on six.PY3 is needlessly complex, six.text_type just does the job.

If we chose this path, in fact, we'd probably just slap force_text around login_url.



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 17, 2012
  1. Rémy HUBSCHER
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 2 deletions.
  1. +9 −2 django/contrib/auth/
11 django/contrib/auth/
@@ -7,6 +7,7 @@
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.core.exceptions import PermissionDenied
from django.utils.decorators import available_attrs
+from django.utils import six
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
@@ -22,15 +23,21 @@ def _wrapped_view(request, *args, **kwargs):
if test_func(request.user):
return view_func(request, *args, **kwargs)
path = request.build_absolute_uri()
+ _login_url = None
+ if login_url is not None:
+ if six.PY3:
+ _login_url = str(login_url)
+ else:
+ _login_url = unicode(login_url)
# If the login url is the same scheme and net location then just
# use the path as the "next" url.
- login_scheme, login_netloc = urlparse(login_url or settings.LOGIN_URL)[:2]
+ login_scheme, login_netloc = urlparse(_login_url or settings.LOGIN_URL)[:2]
current_scheme, current_netloc = urlparse(path)[:2]
if ((not login_scheme or login_scheme == current_scheme) and
(not login_netloc or login_netloc == current_netloc)):
path = request.get_full_path()
from django.contrib.auth.views import redirect_to_login
- return redirect_to_login(path, login_url, redirect_field_name)
+ return redirect_to_login(path, _login_url, redirect_field_name)
return _wrapped_view
return decorator
Something went wrong with that request. Please try again.