Python 2.4 changed ntpath.abspath to do an import
inside the function. As a result, due to Python's
import lock, anything calling abspath on Windows
(directly, or indirectly like tempfile.TemporaryFile)
hung when it was called from a thread spawned as a
side effect of importing a module.
This is a depressingly frequent problem, and
deserves a more general fix. I'm settling for
a micro-fix here because this specific one accounts
for a report of Zope Corp's ZEO hanging on Windows,
and it was an odd way to change abspath to begin
with (ntpath needs a different implementation
depending on whether we're actually running on
Windows, and the _obvious_ way to arrange for that
is not to bury a possibly-failing import _inside_
the function).
Note that if/when other micro-fixes of this kind
get made, the new Lib/test/threaded_import_hangers.py
is a convenient place to add tests for them.
- 'os2' references in ntpath.py relate to the VACPP port, not the EMX port;
- the VACPP port uses the same defpath as all other ntpath.py supported
platforms except 'ce'.
imported on systems other than Windows, and in particular is imported
by test___all__; the compile farm reported that all Linux tests failed
due to this; isn't anyone in PythonDevLand running CVS on Linux?!).
sys.getwindowsversion() on Windows (new enahanced Tim-proof <wink>
version), and fix test_pep277.py in a few minor ways.
Including doc and NEWS entries.
ntpath.join('a', '') was producing 'a' instead of 'a\\' as in 2.1.
Impossible to guess what was ever *intended*, but since split('a\\')
produces ('a', ''), I think it's best if join('a', '') gives 'a\\' back.
Once upon a time, I put together a little function
that tries to find the canonical filename for a given
pathname on POSIX. I've finally gotten around to
turning it into a proper patch with documentation.
On non-POSIX, I made it an alias for 'abspath', as
that's the behavior on POSIX when no symlinks are
encountered in the path.
Example:
>>> os.path.realpath('/usr/bin/X11/X')
'/usr/X11R6/bin/X'
d:/whatever instead of /whatever. While I'm afraid changing isabs()
to be *consistent* with this would break lots of code, it makes
best sense for join() to do it this way. Thanks to Alex Martelli for
pushing back on this one!
This is a Windows-specific glitch that's really due to that, e.g.,
ntpath.join("c:", "/abc") returned "/abc" instead of "c:/abc". Made
join smarter.
Bugfix candidate.
splitunc() parses UNC paths. The contributor of the UNC parsing in
splitdrive() doesn't like it, but I haven't heard a good reason to
keep it, and it causes some problems. (I think there's a
philosophical problem -- to me, the split*() functions are purely
syntactical, and the fact that \\foo is not a valid path doesn't mean
that it shouldn't be considered an absolute path.)
Also (quite separately, but strangely related to the philosophical
issue above) fix abspath() so that if win32api exists, it doesn't fail
when the path doesn't actually exist -- if GetFullPathName() fails,
fall back on the old strategy (join with getcwd() if neccessary, and
then use normpath()).