Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[py3] Fixed contrib.auth tests

  • Loading branch information...
commit 34ac1457962165afbe8203742fdc5308e2979db6 1 parent 367bfaa
Claude Paroz claudep authored
2  django/contrib/auth/management/__init__.py
View
@@ -108,7 +108,7 @@ def get_default_username(check_db=True):
default_username = get_system_username()
try:
default_username = unicodedata.normalize('NFKD', default_username)\
- .encode('ascii', 'ignore').replace(' ', '').lower()
+ .encode('ascii', 'ignore').decode('ascii').replace(' ', '').lower()
except UnicodeDecodeError:
return ''
if not RE_VALID_USERNAME.match(default_username):
3  django/contrib/auth/tests/tokens.py
View
@@ -1,9 +1,11 @@
+import sys
from datetime import date, timedelta
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.test import TestCase
+from django.utils import unittest
class TokenGeneratorTest(TestCase):
@@ -51,6 +53,7 @@ def _today(self):
p2 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS + 1))
self.assertFalse(p2.check_token(user, tk1))
+ @unittest.skipIf(sys.version_info[:2] >= (3, 0), "Unnecessary test with Python 3")
def test_date_length(self):
"""
Make sure we don't allow overly long dates, causing a potential DoS.
2  django/contrib/auth/views.py
View
@@ -200,7 +200,7 @@ def password_reset_confirm(request, uidb36=None, token=None,
try:
uid_int = base36_to_int(uidb36)
user = User.objects.get(id=uid_int)
- except (ValueError, User.DoesNotExist):
+ except (ValueError, OverflowError, User.DoesNotExist):
user = None
if user is not None and token_generator.check_token(user, token):
Please sign in to comment.
Something went wrong with that request. Please try again.