def get_system_username():
    try:
        result = getpass.getuser()
    except (ImportError, KeyError):
        # KeyError will be raised by os.getpwuid() (called by getuser())
        # if there is no corresponding entry in the /etc/passwd file
        # (a very restricted chroot environment, for example).
        return ''
    if six.PY2:
        try:
            result = result.decode(DEFAULT_LOCALE_ENCODING)
        except UnicodeDecodeError:
            # UnicodeDecodeError - preventive treatment for non-latin Windows.
            return ''
    return result
Test working_copy() with sudo as a user
dataset/ETHPy150Open django/django/django/contrib/auth/management/__init__.py/get_system_username--crossover with--dataset/ETHPy150Open ronnix/fabtools/fabtools/tests/functional_tests/test_git.py/test_git_require_sudo_user