Ticket #17185: get_username.patch

File get_username.patch, 787 bytes (added by Niels Poppe, 13 years ago)

patches get_system_username() to function correctly when locale is not set up

  • django/contrib/auth/management/__init__.py

     
    8282        username could not be determined.
    8383    """
    8484    try:
    85         return getpass.getuser().decode(locale.getdefaultlocale()[1])
     85        locale_encoding = locale.getdefaultlocale()[1]
     86        if locale_encoding is None:
     87            locale_encoding = 'ascii'
     88        return getpass.getuser().decode(locale_encoding)
    8689    except (ImportError, KeyError, UnicodeDecodeError):
    8790        # KeyError will be raised by os.getpwuid() (called by getuser())
    8891        # if there is no corresponding entry in the /etc/passwd file
Back to Top