Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#22364 closed Bug (fixed)

changepassword fails on Windows

Reported by: jpaulett Owned by: jpaulett
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 Changed 12 months ago by jpaulett

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 12 months ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 12 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 12 months ago by Tim Graham <timograham@…>

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 Changed 12 months ago by Tim Graham <timograham@…>

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