From dc2e11ed5a5a8083db1d8b5e2396c9238999568c Mon Sep 17 00:00:00 2001 From: andrei kulakov Date: Wed, 8 Sep 2021 13:24:09 -0400 Subject: [PATCH] [3.9] bpo-41082: Add note on errors that may be raised by home() and expanduser() (GH-28186) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Co-authored-by: Łukasz Langa --- Doc/library/pathlib.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index c31ff6543aee..88e8756cf84a 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -708,6 +708,10 @@ call fails (for example because the path doesn't exist). >>> Path.home() PosixPath('/home/antoine') + Note that unlike :func:`os.path.expanduser`, on POSIX systems a + :exc:`KeyError` or :exc:`RuntimeError` will be raised, and on Windows systems a + :exc:`RuntimeError` will be raised if home directory can't be resolved. + .. versionadded:: 3.5 @@ -764,6 +768,10 @@ call fails (for example because the path doesn't exist). >>> p.expanduser() PosixPath('/home/eric/films/Monty Python') + Note that unlike :func:`os.path.expanduser`, on POSIX systems a + :exc:`KeyError` or :exc:`RuntimeError` will be raised, and on Windows systems a + :exc:`RuntimeError` will be raised if home directory can't be resolved. + .. versionadded:: 3.5 -- 2.47.3