Opened 13 years ago
Closed 13 years ago
#17022 closed Bug (duplicate)
createsuperuser / get_default_username fail on systems without default locale encoding
Reported by: | Preston Holmes | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (1)
Change History (2)
by , 13 years ago
Attachment: | get_system_username.diff added |
---|
comment:1 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Already reported in #16017