Brian Curtin <br...@python.org> added the comment:

Attached is a complete patch. All tests pass.

Lib/test/support.py
 * Handle AttributeError, which Hirokazu noticed on pre-XP machines

Lib/test/test_os.py
 * This sets up a three-deep directory tree and creates a symbolic link in the 
middle (second) directory.
 * os.stat calls are tested from below, equal to, and above the symbolic link 
to make sure they work. This is what was broken with the previous os.stat 
implementation on Windows, as it used a method which only provided correct 
information (the reparse tag) when the stat call was made from the directory 
where the link originates from.

Modules/posixmodule.c
 * win32_read_link, now called win32_get_reparse_tag, was changed to just get 
the reparse tag and that's it. The tag is now only used when setting the mode 
attribute based on if the tag shows that this is a symlink directory or file.

 * The GetFinalPathNameByHandle dynamic loading and preparing was moved up in 
the file since it is again used for stat calls.

 * I removed the major duplication of stat implementations for both narrow and 
wide paths. Now there is just one implementation, win32_xstat_impl, which 
accepts a wide path and does the same work.

 * win32_xstat_impl now takes an approach where if there's a symlink to be 
traversed, e.g., for an os.stat call, the path is then re-opened without the 
flag to open the reparse tag, effectively following the link path. Then we pass 
the newly opened file handle to GetFinalPathNameByHandle and we can get back 
the target path, which we then pass recursively. There's no more depth stuff - 
we either try to follow the link in the above fashion or not.

 * win32_lstat was never being called from anywhere so it was removed.

 * win32_stat, which takes a narrow path, is now converted early to a wide path 
and passed into the win32_xstat_impl rather than maintaining two of the same 
functions like before.

----------
keywords: +needs review
Added file: http://bugs.python.org/file22224/issue12084.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12084>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to