Issue 28477: Add optional user argument to pathlib.Path.home() (original) (raw)

Issue28477

Created on 2016-10-19 17:34 by josh.r, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg278988 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2016-10-19 17:34
os.path.expanduser supports both '~' and '~username` constructs to get home directories. It seems reasonable for pathlib.Path.home to default to getting the current user's home directory, but support passing an argument to get the home directory for another user. It means no need to use os.path.expanduser for the purpose (which always strikes me as a little "ugly" for portable code; the ~ works, but it's using UNIX syntax in a way that makes it feel non-portable), making pathlib a more complete replacement.
msg278989 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-19 18:17
pathlib.Path.home() don't support the user argument for reasons. The main problem is that os.path.expanduser() for other users is faked on Windows. It uses guessing, and perhaps it returns correct result in most cases. But in non-standard situations, if current user or other users have non-default home directory, it returns wrong result. I don't know wherever it works for users with non-ascii names or names containing special characters.
History
Date User Action Args
2022-04-11 14:58:38 admin set github: 72663
2022-01-19 00:12:53 iritkatriel set status: open -> closedresolution: rejectedstage: resolved
2016-10-19 18:17:27 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2016-10-19 17:34:22 josh.r create