Ticket #17022: get_system_username.diff

File get_system_username.diff, 718 bytes (added by Preston Holmes, 9 years ago)
  • django/contrib/auth/management/__init__.py

    diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
    index 532654f..bfc07ea 100644
    a b def get_system_username(): 
    8282        username could not be determined.
    8383    """
    8484    try:
    85         return getpass.getuser().decode(locale.getdefaultlocale()[1])
     85        encoding = locale.getdefaultlocale()[1] or 'UTF8'
     86        return getpass.getuser().decode(encoding)
    8687    except (ImportError, KeyError, UnicodeDecodeError):
    8788        # KeyError will be raised by os.getpwuid() (called by getuser())
    8889        # if there is no corresponding entry in the /etc/passwd file
Back to Top