classification
Title: extending os.walk to support following symlinks
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: zseil Nosy List: aptshansen, georg.brandl, georg.brandl, idadesub, loewis, tmick, zseil
Priority: normal Keywords: patch

Created on 2005-08-26 07:21 by idadesub, last changed 2007-04-09 16:07 by tmick. This issue is now closed.

Files
File name Uploaded Description Edit
os.py.diff idadesub, 2005-08-26 07:21 patch against the cvs version of os.py
test_os.diff zseil, 2007-04-03 06:27 test_os windows fix against trunk revision 54670
Messages (11)
msg48670 - (view) Author: Erick Tryzelaar (idadesub) Date: 2005-08-26 07:21
this is a very simple extension to os.walk to optionally walk down 
into symlink directories, when it is supported by the operating 
system. This patch keeps a compatible interface by having this 
option disabled. 
msg48671 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-08-26 08:23
Logged In: YES 
user_id=1188172

The docs to os.walk say:
"""
Note: On systems that support symbolic links, links to
subdirectories appear in dirnames lists, but walk() will not
visit them (infinite loops are hard to avoid when following
symbolic links). To visit linked directories, you can
identify them with os.path.islink(path), and invoke
walk(path) on each directly.
"""

Nevertheless, we could offer this option with a caution message.
msg48672 - (view) Author: Stephen Hansen (aptshansen) Date: 2007-03-16 07:34
I'm not sure if this is a good idea; although I am certain it would be useful at times. Dangerous! But if its documented, ... and there's our problem :)

Patch applies cleanly to the HEAD, but needs documentation.
msg48673 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-16 08:22
Added docs and tests and committed in rev. 54407.
msg48674 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-03-23 15:31
The test suite patch (54482) broke the windows build. The assertion

self.assertEqual(len(all), 4)

fails because it finds 5 directories (link is a directory), then the rest of the 
code is not executed. In turn, the tear-down code is not run, leaving the directories
behind. This causes subsequent tests to fail.

When fixing the code, I recommend to move the tear-down code into the tearDown
method of the test, to make sure it is always run.
msg48675 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2007-04-03 06:27
Here is a patch that fixes test_os.WalkTests on Windows.

I also added a tearDown method to WalkTests and removed
Collin's changes to MakedirTests, because they are not
needed anymore.

File Added: test_os.diff
msg48676 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-04-04 18:09
The patch is fine; please apply.
msg48677 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2007-04-04 18:41
Commited as revision 54689.
msg48678 - (view) Author: Trent Mick (tmick) Date: 2007-04-04 21:59
Is there a separate bug for doc updates for this?
msg48679 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2007-04-07 00:10
Hi Trent,

There is no separate issue yet. What is missing in
the docs?  Georg updated the docs when he checked
in this patch.
msg48680 - (view) Author: Trent Mick (tmick) Date: 2007-04-09 16:07
Ziga,
My mistake: I failed to notice the change to Doc/lib/libos.tex.
History
Date User Action Args
2005-08-26 07:21:24idadesubcreate