﻿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
17185	[patch] manage.py createsuperuser fails when locale is not set	Niels Poppe	nobody	"When locale(1) is like\\
`LANG=`\\
`LC_CTYPE=""C""`\\
`LC_COLLATE=""C""`\\
`LC_TIME=""C""`\\
`LC_NUMERIC=""C""`\\
`LC_MONETARY=""C""`\\
`LC_MESSAGES=""C""`\\
`LC_ALL=`\\

then ""./manage.py createsuperuser"" results in a traceback ending
{{{
File ""/usr/lib/py-dev/django-trunk/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
}}}

Since get_system_username() tries to guard against restricted environments like being run in a chroot() environment chances are there is no sane LANG environment either — resulting in getdefaultlocale() returning (None, None).

Assuming ascii encoding is probably okay because !UnicodeDecodeError is catched anyway. Calling decode() with ‘ignore’ or not is a matter of taste.

See attached patch."	Bug	closed	contrib.auth	1.3	Normal	duplicate			Unreviewed	1	0	0	0	1	0
