not quite minimalistic enough  

Oh no, not again ...

The Python-on-Windows people are at it again. This time they have deliberately broken os.path.expanduser() in 3.8.

Until 3.7, expanduser() treated a tilde at the front of the path given to it the same as a *ix shell, i.e. ‘~/’ was replaced by the current user’s home directory, and ‘~user/’ with that of user user. More specifically, it used the value of the HOME environment variable, or USERPROFILE if the former did not exist, or HOMEDRIVE\HOMEPATH as a final fallback (on NT 3.51, perhaps?).

Then someone complained about that, Python bug #36264, and for some reason unknown to the world, it was decided not to consider HOME anymore.

This (and I’m speaking out of a deep personal animus) was the most misguided decision since splitting the Windows distribution into 22 MSI packages per architecture.


Because the supposed rationale for the change is that HOME is not a “special” variable on Windows, i.e. it is not something the system/shell cares more about than any other environment variable.

So what? It was documented that it was used by expanduser(), and that is what matters. Explicitly mentioning some behavior in the documentation, without a note that it is an implementation detail subject to change, is what interface contracts are made of.

The documentation does not make any claims that HOME is used because it is of any particularly exalted rank, it simply says it is used. The relevant paragraph could even be read simply as “the user’s home directory, unless overridden with HOME”.

In a particularly cruel twist, the original complainant even pointed out that their problem was actually caused by a bug in MSYS, but the Python-on-Windows maintainer apparently felt that this localized problem with a single tool merited breaking part of the Python standard library for everyone. (The tool was Git, but still …)

Written on October 22, 2019