Skip to content

Commit 8ef864d

Browse files
authored
bpo-36264: Updates documentation for change to expanduser on Windows (GH-12294)
1 parent f45813d commit 8ef864d

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Doc/library/os.path.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,20 @@ the :mod:`glob` module.)
172172
password directory through the built-in module :mod:`pwd`. An initial ``~user``
173173
is looked up directly in the password directory.
174174

175-
On Windows, :envvar:`HOME` and :envvar:`USERPROFILE` will be used if set,
176-
otherwise a combination of :envvar:`HOMEPATH` and :envvar:`HOMEDRIVE` will be
177-
used. An initial ``~user`` is handled by stripping the last directory component
178-
from the created user path derived above.
175+
On Windows, :envvar:`USERPROFILE` will be used if set, otherwise a combination
176+
of :envvar:`HOMEPATH` and :envvar:`HOMEDRIVE` will be used. An initial
177+
``~user`` is handled by stripping the last directory component from the created
178+
user path derived above.
179179

180180
If the expansion fails or if the path does not begin with a tilde, the path is
181181
returned unchanged.
182182

183183
.. versionchanged:: 3.6
184184
Accepts a :term:`path-like object`.
185185

186+
.. versionchanged:: 3.8
187+
No longer uses :envvar:`HOME` on Windows.
188+
186189
.. index::
187190
single: $ (dollar); environment variables expansion
188191
single: % (percent); environment variables expansion (Windows)

Doc/whatsnew/3.8.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ now return ``False`` instead of raising :exc:`ValueError` or its subclasses
236236
characters or bytes unrepresentable at the OS level.
237237
(Contributed by Serhiy Storchaka in :issue:`33721`.)
238238

239+
:func:`~os.path.expanduser` on Windows now prefers the :envvar:`USERPROFILE`
240+
environment variable and does not use :envvar:`HOME`, which is not normally set
241+
for regular user accounts.
242+
239243

240244
ncurses
241245
-------
@@ -672,6 +676,10 @@ Changes in the Python API
672676
:exc:`dbm.gnu.error` or :exc:`dbm.ndbm.error`) instead of :exc:`KeyError`.
673677
(Contributed by Xiang Zhang in :issue:`33106`.)
674678

679+
* :func:`~os.path.expanduser` on Windows now prefers the :envvar:`USERPROFILE`
680+
environment variable and does not use :envvar:`HOME`, which is not normally
681+
set for regular user accounts.
682+
675683

676684
CPython bytecode changes
677685
------------------------

0 commit comments

Comments
 (0)