-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_walk fails on Linux #4
Comments
Same problem on Ubuntu 13.04. Also, the test does not work on python2:
|
We need to do an os.stat call for symlinks to see if they point at a file or directory. I am not sure if there is a more efficient way to do this in windows. I went ahead and added caching of the os.stat result too.
The original issue doesn't happen anymore, closing. @Malizor, if the issue you brought up still happens on Ubuntu, please open a new issue. |
Okay, the original issue as described does still happen on Linux, reopening. I'm going to edit the description of this issue to match the current symptoms. |
What is the status of this issue? As moloney found, it seems the only way around this is to fallback to a symlink-following stat() call when d_type == DT_LNK (in is_dir and is_file). Is there still some kind of decision to made about this? |
I need to review and test the fix. I'm back working on scandir (particularly PEP 471 at the moment), so I'll try to get to this in the next week or two. |
Note to self: this is easy to repro on Windows just by setting |
This is actually happening because scandir.py's definition of walk() is not putting symlinks to directories in the right list. See also https://mail.python.org/pipermail/python-dev/2014-July/135401.html Fix should be simple enough -- I'll commit in the next few days. |
Maybe I should've fleshed out my previous comment a little more.. I began to note it was down to the difference between lstat and stat but I thought you were already aware. Ideally paying the price for a full stat() would only happen when it's a symlink. |
Fixed in e601121 |
Ben, with that change scandir.walk will now put symlinks to files in the directories list when followlinks=False. This does not match what os.walk does. As a side note, I think I might be of the opinion that is_file/is_dir should always use stat instead of lstat when the file is a symlink, which would match os.path.isdir/isfile. What is the reason to the current is_dir/is_file implementation? |
You're dead right. Thank you. |
…nk cases. Add explicit unit tests for this.
I realized I was overthinking it. To mimic os.walk(), I just need to use I've fixed this in 4907dc7 and added explicit unit tests to catch this. Tested on Python 3.4 on Windows, about about to test on Python 2.6 on Linux. Does this look right to you? |
Yep, works on Linux on python 2.6 fine too. Haven't tested Python 3 on Linux, but hoping for the best. :-) |
8 passed in 0.27 seconds (from 4907dc7) on both: platform linux2 -- Python 3.2.3 -- py-1.4.20 -- pytest-2.5.2 |
I think this is all fixed now, closing. |
The text was updated successfully, but these errors were encountered: