[Patches] [ python-Patches-1273829 ] extending os.walk to support following symlinks

SourceForge.net noreply at sourceforge.net
Wed Apr 4 20:41:03 CEST 2007


Patches item #1273829, was opened at 2005-08-26 09:21
Message generated for change (Comment added) made by zseil
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1273829&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Resolution: Accepted
Priority: 5
Private: No
Submitted By: Erick Tryzelaar (idadesub)
Assigned to: Ziga Seilnacht (zseil)
Summary: extending os.walk to support following symlinks

Initial Comment:
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. 

----------------------------------------------------------------------

>Comment By: Ziga Seilnacht (zseil)
Date: 2007-04-04 20:41

Message:
Logged In: YES 
user_id=1326842
Originator: NO

Commited as revision 54689.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2007-04-04 20:09

Message:
Logged In: YES 
user_id=21627
Originator: NO

The patch is fine; please apply.

----------------------------------------------------------------------

Comment By: Ziga Seilnacht (zseil)
Date: 2007-04-03 08:27

Message:
Logged In: YES 
user_id=1326842
Originator: NO

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

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-23 16:31

Message:
Logged In: YES 
user_id=21627
Originator: NO

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.

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-16 09:22

Message:
Logged In: YES 
user_id=849994
Originator: NO

Added docs and tests and committed in rev. 54407.

----------------------------------------------------------------------

Comment By: Stephen Hansen (aptshansen)
Date: 2007-03-16 08:34

Message:
Logged In: YES 
user_id=1720594
Originator: NO

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.

----------------------------------------------------------------------

Comment By: Georg Brandl (birkenfeld)
Date: 2005-08-26 10:23

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1273829&group_id=5470


More information about the Patches mailing list