This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients 4-launchpad-kalvdans-no-ip-org, Jim Fasarakis-Hilliard, barneygale, brett.cannon, docs@python, eryksun, methane, pitrou, serhiy.storchaka
Date 2022-01-31.22:07:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643666845.49.0.827806098633.issue29688@roundup.psfhosted.org>
In-reply-to
Content
> I'm not seeing what's wrong with your example.

"C:" or "C:spam\\eggs" are not absolute paths. They depend on the effective working directory on the drive. An absolute path should never depend on a working directory, which can change at random.

WinAPI SetEnvironmentVariableW() allows applications to set environment variables with names that begin with "=". These names are effectively reserved for special use by the OS, at least as documented. In particular, names of the form "=X:", where "X" is a drive letter, are used to store the working directory on a drive. The C runtime _[w]chdir() function sets these per-drive environment variables, as does Python's os.chdir(). As environment variables, they can be inherited by child processes.

When then Windows API resolves a file path to access a file, or in GetFullPathNameW(), a drive-relative path such as "X:" or "X:spam\\eggs" is resolved against either the current working directory (if it's on the drive) or the value of the "=X:" environment variable for the drive. If the latter isn't defined, it defaults to the root directory, e.g. "X:\\". If the current working directory is on the drive, the system updates the value of the "=X:" environment variable, if it exists.

> on Windows you have to resolve the drive separately from the 
> working directory and then concatenate them?

Yes, if self.drive is defined. This would be handled by os.path.abspath(self.drive), which calls WinAPI GetFullPathNameW().
History
Date User Action Args
2022-01-31 22:09:07eryksununlinkissue29688 messages
2022-01-31 22:07:25eryksunsetrecipients: + eryksun, brett.cannon, pitrou, methane, docs@python, serhiy.storchaka, Jim Fasarakis-Hilliard, 4-launchpad-kalvdans-no-ip-org, barneygale
2022-01-31 22:07:25eryksunsetmessageid: <1643666845.49.0.827806098633.issue29688@roundup.psfhosted.org>
2022-01-31 22:07:25eryksunlinkissue29688 messages
2022-01-31 22:07:25eryksuncreate