summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Lønne <jon@funkbit.no>2013-12-18 20:04:53 +0100
committerTim Graham <timograham@gmail.com>2013-12-26 07:46:12 -0500
commit0e8138349ef7f30f6042853b10f28be7301c20ca (patch)
tree4fb21de90275a3e3f63c81f8a700bf25fc6f2044
parentb536ad09cadc087b7559db2f8cca50f06c6e8f34 (diff)
[1.6.x] Fixed #21627 -- Added unicode_literals to changepassword command.
Fixed a crash when executing changepassword command when the user object representation contained non-ASCII characters. Backport of 398642fd9b from master
-rw-r--r--django/contrib/auth/management/commands/changepassword.py2
-rw-r--r--django/contrib/auth/tests/test_management.py12
-rw-r--r--docs/releases/1.6.2.txt3
3 files changed, 17 insertions, 0 deletions
diff --git a/django/contrib/auth/management/commands/changepassword.py b/django/contrib/auth/management/commands/changepassword.py
index 3240b0f992..b68e714d70 100644
--- a/django/contrib/auth/management/commands/changepassword.py
+++ b/django/contrib/auth/management/commands/changepassword.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
import getpass
from optparse import make_option
diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py
index c6d4dd5b7c..91a7cab632 100644
--- a/django/contrib/auth/tests/test_management.py
+++ b/django/contrib/auth/tests/test_management.py
@@ -82,6 +82,18 @@ class ChangepasswordManagementCommandTestCase(TestCase):
with self.assertRaises(CommandError):
command.execute("joe", stdout=self.stdout, stderr=self.stderr)
+ def test_that_changepassword_command_works_with_nonascii_output(self):
+ """
+ #21627 -- Executing the changepassword management command should allow
+ non-ASCII characters from the User object representation.
+ """
+ # 'Julia' with accented 'u':
+ models.User.objects.create_user(username='J\xfalia', password='qwerty')
+
+ command = changepassword.Command()
+ command._get_pass = lambda *args: 'not qwerty'
+
+ command.execute("J\xfalia", stdout=self.stdout)
@skipIfCustomUser
class CreatesuperuserManagementCommandTestCase(TestCase):
diff --git a/docs/releases/1.6.2.txt b/docs/releases/1.6.2.txt
index fa8bd5bc93..41bc86e906 100644
--- a/docs/releases/1.6.2.txt
+++ b/docs/releases/1.6.2.txt
@@ -11,3 +11,6 @@ Bug fixes
* Prevented the base geometry object of a prepared geometry to be garbage
collected, which could lead to crash Django (#21662).
+
+* Fixed a crash when executing the :djadmin:`changepassword` command when the
+ user object representation contained non-ASCII characters (#21627).