'descend' argument in 'walk' method in twisted.python.filepath._PathHelper class doesn't work well

[email protected]
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from Markon <None>:

The 'walk' method in the class _PathHelper, located in twisted/python/filepath.py doesn't work according to the 'descend' argument passed.
This is an example:

{{{
>>> import twisted.python.filepath as FP
>>> filep = FP.FilePath("/home/marco/Desktop")
>>> for x in filep.walk(lambda path: not path.islink()):
...     print x
...
FilePath('/home/marco/Desktop')
FilePath('/home/marco/Desktop/amarok.desktop')
[...]
FilePath('/home/marco/Desktop/MyFolder')
FilePath('/home/marco/Desktop/MyFolder/myfile.txt')
[...]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/twisted/python/filepath.py", line 214, in walk
    raise LinkError("Cycle in file graph.")
twisted.python.filepath.LinkError: Cycle in file graph.

}}}

In the Desktop directory there's a symlink "Risorse", which points to "/home/marco". So it creates a cycle, ok. But I've specified the descend argument and it shouldn't follow the link.

However, I've also provided a patch, and if I use it, the argument 'descend' is read fine:


{{{
>>> import filepath as FP
>>> filep = FP.FilePath("/home/marco/Desktop")
>>> for x in filep.walk(lambda path: not path.islink()):
...     print x
...
FilePath('/home/marco/Desktop')
FilePath('/home/marco/Desktop/amarok.desktop')
[...]
FilePath('/home/marco/Desktop/MyFolder')
FilePath('/home/marco/Desktop/MyFolder/myfile.txt')
[...]
FilePath('/home/marco/Desktop/Risorse') <<<---- this is the cyclic symlink
[... other files ...]

}}}

I should write the tests, but in the meantime I attach the patch I've written.






----------
Type     : defect
Component: core
Keywords : 
Priority : high
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/3911
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.