Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#22364 closed Bug (fixed)

changepassword fails on Windows

Reported by: John Paulett Owned by: John Paulett
Component: contrib.auth Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

"manage.py changepassword" fails on Windows 2008 R2 and Windows 7 due to getpass receiving an unicode string.

C:\project>manage.py changepassword bob
Changing password for user 'bob'
Traceback (most recent call last):
    djangorecipe.manage.main('test_project.settings')
  File "C:\project\vendor\djangorecipe\src\djangorecipe\manage.py", line 9, in main
    management.execute_from_command_line(sys.argv)
  File "C:\project\eggs\django-1.6.2-py2.7.egg\django\core\management\__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "C:\project\eggs\django-1.6.2-py2.7.egg\django\core\management\__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\project\eggs\django-1.6.2-py2.7.egg\django\core\management\base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\project\eggs\django-1.6.2-py2.7.egg\django\core\management\base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "C:\project\eggs\django-1.6.2-py2.7.egg\django\contrib\auth\management\commands\changepassword.py", line 50, in handle
    p1 = self._get_pass()
  File "C:\project\eggs\django-1.6.2-py2.7.egg\django\contrib\auth\management\commands\changepassword.py", line 21, in _get_pass
    p = getpass.getpass(prompt=prompt)
  File "C:\Python27\lib\getpass.py", line 95, in win_getpass
    msvcrt.putch(c)
TypeError: must be char, not unicode

Related to #19807, which had the same error in createsuperuser on Windows. I have tested the same solution to force_str and it resolves the issue (Pull Request is incoming). On other OSes, everything works fine.

This appears to be a regression was introduced in 1.5 and is still present today. changepassword on Windows worked under 1.4. It definitely seems relevant to include in the 1.7 release and potentially as a bug fix release for 1.5 & 1.6. I found no other reports of this error, so there does not seem to be a large affected population, but would be helpful to me to have as part of any upcoming 1.6.x bug fix release (I do have a workaround under 1.6 until then).

Change History (5)

comment:1 by John Paulett, 11 years ago

Issued Pull Request 2503. Verified fix in application on Windows 7. All tests passing using default runtests.py.

comment:2 by Alex Gaynor, 11 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In b5a9166f7e0e21ae0f2cc8f218b422bc2c116fb0:

Fixed #22364 -- Sanitized getpass input in changepassword.

Python 2 getpass on Windows does not accept unicode, even
when containing on ASCII characters. Related #190807.

comment:4 by Tim Graham <timograham@…>, 11 years ago

In b4681be154dd7194041e94f3eb6d7f24217b9a1b:

[1.7.x] Fixed #22364 -- Sanitized getpass input in changepassword.

Python 2 getpass on Windows does not accept unicode, even
when containing on ASCII characters. Related #190807.

Backport of b5a9166f7e from master

comment:5 by Tim Graham <timograham@…>, 11 years ago

In 129cb7e2228cf076104eb5de69e6063f1bf34dd9:

[1.6.x] Fixed #22364 -- Sanitized getpass input in changepassword.

Python 2 getpass on Windows does not accept unicode, even
when containing on ASCII characters. Related #190807.

Backport of b5a9166f7e from master

Note: See TracTickets for help on using tickets.
Back to Top