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.

classification
Title: Error handling and documentation of Path.home()
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: andrei.avk, lukasz.langa, timhoffm
Priority: normal Keywords: patch

Created on 2020-06-22 21:13 by timhoffm, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 28186 merged andrei.avk, 2021-09-06 17:33
Messages (6)
msg372116 - (view) Author: Tim Hoffmann (timhoffm) * Date: 2020-06-22 21:13
Path.home() may fail un
(https://github.com/matplotlib/matplotlib/issues/17707#issuecomment-647180252).

1. I think the raised key error is too low-level, and it should be something else; what exactly t.b.d.
2. The documentation (https://docs.python.org/3/library/pathlib.html#pathlib.Path.home) should specify what happens in case of failure.
3. The documentation links to https://docs.python.org/3/library/os.path.html#os.path.expanduser, but that's not correct. _PosixFlavor.gethomedir() implements it's own user lookup, which is slightly different from os.path.expanduser()
msg399598 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-08-14 22:08
In current dev version (3.11), _PosixFlavor doesn't have gethomedir(), and instead os.path.expanduser() is used via _NormalAccessor(). So at least for the current dev version, the docs are accurate.
msg401166 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-09-06 17:36
I looked a bit more into this, it's been fixed in 3.10, in this PR: https://github.com/python/cpython/pull/18841

It wasn't backported to 3.9. I'm not quite sure if it's best to backport to 3.9 or fix via docs for 3.9. Just in case I've put up a small PR for such a docfix.
msg401404 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-08 16:58
Using `os.path.expanduser` is a functional change so it wasn't backported at the time to 3.9 and sure shouldn't be backported now. Going with a doc update is the right approach.
msg401412 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-08 17:24
New changeset dc2e11ed5a5a8083db1d8b5e2396c9238999568c by andrei kulakov in branch '3.9':
[3.9] bpo-41082: Add note on errors that may be raised by home() and expanduser() (GH-28186)
https://github.com/python/cpython/commit/dc2e11ed5a5a8083db1d8b5e2396c9238999568c
msg401414 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-08 17:28
Behavior is fixed in Python 3.10+. For Python 3.9 the docs are updated to list possible exceptions. Since this was reported with 3.9 in mind, I'm marking this one as wontfix.

Thanks for picking this up, Andrei! ✨ 🍰 ✨
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85254
2021-09-08 17:28:49lukasz.langasetstatus: open -> closed
resolution: wont fix
messages: + msg401414

stage: patch review -> resolved
2021-09-08 17:24:17lukasz.langasetmessages: + msg401412
2021-09-08 16:58:14lukasz.langasetnosy: + lukasz.langa
messages: + msg401404
2021-09-06 17:36:46andrei.avksetversions: + Python 3.9
2021-09-06 17:36:22andrei.avksetmessages: + msg401166
2021-09-06 17:33:20andrei.avksetkeywords: + patch
stage: patch review
pull_requests: + pull_request26614
2021-08-14 22:08:42andrei.avksetnosy: + andrei.avk
messages: + msg399598
2020-06-22 21:13:41timhoffmcreate