﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17022	createsuperuser / get_default_username fail on systems without default locale encoding	Preston Holmes	nobody	"r16182 introduced a regression in the case of systems that, for whatever reason, don't provide a locale encoding.

For example on OS X Server 10.6:

{{{
>>> import locale
>>> locale.getdefaultlocale()
(None, None)
}}}

as documented for the locale module, None is a valid return value:

http://docs.python.org/library/locale.html#locale.getdefaultlocale

However, the decode function does not allow None and will raise a TypeError:

{{{
>>> get_default_username()
Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
  File ""/private/tmp/foo/src/django/django/contrib/auth/management/__init__.py"", line 105, in get_default_username
    default_username = get_system_username()
  File ""/private/tmp/foo/src/django/django/contrib/auth/management/__init__.py"", line 85, in get_system_username
    return getpass.getuser().decode(locale.getdefaultlocale()[1])
TypeError: decode() argument 1 must be string, not None
}}}

the attach patch should fix this for most cases, since UTF8 is the best default

however, short of mocking locale.getdefaultlocale, I'm not sure how to test this.


"	Bug	closed	contrib.auth	dev	Release blocker	duplicate			Unreviewed	1	0	0	0	0	0
