From 463bafb7169ca7bc4ac2a8cf1fee438361c91e7c Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 12 Mar 2019 09:02:56 -0700 Subject: [PATCH 1/2] bpo-36264: Updates documentation for change to expanduser on Windows --- Doc/library/os.path.rst | 11 +++++++---- Doc/whatsnew/3.8.rst | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index ebbf63cc3548c4..a167e3b885fdfc 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -172,10 +172,10 @@ the :mod:`glob` module.) password directory through the built-in module :mod:`pwd`. An initial ``~user`` is looked up directly in the password directory. - On Windows, :envvar:`HOME` and :envvar:`USERPROFILE` will be used if set, - otherwise a combination of :envvar:`HOMEPATH` and :envvar:`HOMEDRIVE` will be - used. An initial ``~user`` is handled by stripping the last directory component - from the created user path derived above. + On Windows, :envvar:`USERPROFILE` will be used if set, otherwise a combination + of :envvar:`HOMEPATH` and :envvar:`HOMEDRIVE` will be used. An initial + ``~user`` is handled by stripping the last directory component from the created + user path derived above. If the expansion fails or if the path does not begin with a tilde, the path is returned unchanged. @@ -183,6 +183,9 @@ the :mod:`glob` module.) .. versionchanged:: 3.6 Accepts a :term:`path-like object`. + .. versionchanged:: 3.8 + No longer uses :envvar:`HOME` on Windows. + .. index:: single: $ (dollar); environment variables expansion single: % (percent); environment variables expansion (Windows) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index ad86917d0cc71a..a829ae463b1913 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -236,6 +236,10 @@ now return ``False`` instead of raising :exc:`ValueError` or its subclasses characters or bytes unrepresentable at the OS level. (Contributed by Serhiy Storchaka in :issue:`33721`.) +:func:`~os.path.expanduser` on Windows now prefers the :envvar:`USERPROFILE` +environment variable and does not use :envvar:`HOME`, which is not normally set +for regular user accounts. + ncurses ------- From 4636f9ab805d16bea8c4dbaf1285eaedd73333e1 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 12 Mar 2019 11:39:47 -0700 Subject: [PATCH 2/2] Also add to API Changes section --- Doc/whatsnew/3.8.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index a829ae463b1913..4adeded3037502 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -676,6 +676,10 @@ Changes in the Python API :exc:`dbm.gnu.error` or :exc:`dbm.ndbm.error`) instead of :exc:`KeyError`. (Contributed by Xiang Zhang in :issue:`33106`.) +* :func:`~os.path.expanduser` on Windows now prefers the :envvar:`USERPROFILE` + environment variable and does not use :envvar:`HOME`, which is not normally + set for regular user accounts. + CPython bytecode changes ------------------------