Message412220
> 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(). |
|
Date |
User |
Action |
Args |
2022-01-31 22:09:07 | eryksun | unlink | issue29688 messages |
2022-01-31 22:07:25 | eryksun | set | recipients:
+ eryksun, brett.cannon, pitrou, methane, docs@python, serhiy.storchaka, Jim Fasarakis-Hilliard, 4-launchpad-kalvdans-no-ip-org, barneygale |
2022-01-31 22:07:25 | eryksun | set | messageid: <1643666845.49.0.827806098633.issue29688@roundup.psfhosted.org> |
2022-01-31 22:07:25 | eryksun | link | issue29688 messages |
2022-01-31 22:07:25 | eryksun | create | |
|