From a05e1e7a8c1b3cc81cfca3c46e1162659a80ca02 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 29 Jun 2026 12:06:14 +0300 Subject: [PATCH] gh-71450: Document that Tcl sets the HOME variable on Windows Also fix the ntpath.expanduser() docstring, which no longer uses $HOME. Co-Authored-By: Claude Opus 4.8 --- Doc/library/tkinter.rst | 8 ++++++++ Lib/ntpath.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst index 64ef07ede6fbda..cf342d74bc433e 100644 --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -3394,6 +3394,14 @@ Toplevel widgets profile files is the :envvar:`HOME` environment variable or, if that isn't defined, then :data:`os.curdir`. + .. note:: + + On Windows, creating a Tcl interpreter (by instantiating :class:`Tk` or + calling :func:`Tcl`) sets the :envvar:`HOME` environment variable for + the process, if it is not already set, to ``%HOMEDRIVE%%HOMEPATH%`` (or + :envvar:`USERPROFILE`, or ``c:\``). This is done by Tcl and can affect + other code that reads :envvar:`HOME`. + .. attribute:: tk The Tk application object created by instantiating :class:`Tk`. This diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 811e796f7766e9..b3c23f0abc2d88 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -345,7 +345,7 @@ def _isreservedname(name): def expanduser(path): """Expand ~ and ~user constructs. - If user or $HOME is unknown, do nothing.""" + If user or home directory is unknown, do nothing.""" path = os.fspath(path) if isinstance(path, bytes): seps = b'\\/'