[3.12] gh-117503: Fix support of non-ASCII user names in posixpath.expanduser() (GH-117504) (GH-117970)

They are now supported in bytes paths as well as in string paths.
(cherry picked from commit 51132da0c4)
This commit is contained in:
Serhiy Storchaka 2024-04-17 13:43:37 +03:00 committed by GitHub
parent ac48fdeb0d
commit 96b29b32c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View file

@ -290,7 +290,7 @@ def expanduser(path):
return path
name = path[1:i]
if isinstance(name, bytes):
name = str(name, 'ASCII')
name = os.fsdecode(name)
try:
pwent = pwd.getpwnam(name)
except KeyError: