This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients barneygale, eryksun, serhiy.storchaka, steve.dower
Date 2021-04-07.23:29:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617838182.02.0.169681857307.issue39899@roundup.psfhosted.org>
In-reply-to
Content
For a "~user" path, the value of userhome should always be used if target_user == current_user. If for some reason the USERPROFILE environment variable isn't defined, the fallback "%HOMEDRIVE%%HOMEPATH%" does not necessarily end in the user's name. Example rewrite:

    if i != 1: #~user
        target_user = path[1:i]
        if isinstance(target_user, bytes):
            target_user = os.fsdecode(target_user)
        current_user = os.environ.get('USERNAME')

        if target_user != current_user:
            # Try to guess user home directory.  By default all user
            # profile directories are located in the same place and are
            # named by corresponding usernames.  If userhome isn't a
            # normal profile directory, this guess is likely wrong,
            # so we bail out.
            if current_user != basename(userhome):
                return path
            userhome = join(dirname(userhome), target_user)
History
Date User Action Args
2021-04-07 23:29:42eryksunsetrecipients: + eryksun, serhiy.storchaka, steve.dower, barneygale
2021-04-07 23:29:42eryksunsetmessageid: <1617838182.02.0.169681857307.issue39899@roundup.psfhosted.org>
2021-04-07 23:29:42eryksunlinkissue39899 messages
2021-04-07 23:29:41eryksuncreate