-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
On Windows os.listdir('') -> cwd and os.listdir(u'') -> C:\ #50163
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
Comments
On Windows, with Python2/Python3, os.listdir('')/os.listdir(b'') list On Linux the error "OSError: [Errno 2] No such file or directory: ''" is I also noticed that os.listdir('C:') (without the \) lists the content |
As for the "C:" behaviour, I think it is normal: you are not specifying As for '' and b'', I think that ambiguity is bad and these values should |
Before anything is changed, I would first like to understand where the If it gives ENOENT on Unix, it should also give ENOENT on Windows |
On Sun, 3 May 2009 at 17:36, Antoine Pitrou wrote:
It is normal behavior for Windows. Try it with the 'dir' command |
I hope attached patch works. >>> import os
>>> os.listdir("")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
WindowsError: [Error 3] 指定されたパスが見つかりません。: ''
[36200 refs]
>>> os.listdir(u"")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
WindowsError: [Error 3] 指定されたパスが見つかりません。: u'' # Error message says "Cannot find specified path" |
For u"", os.listdir calls FindFirstFileW with u"\\*.*", The code before FindFirstFile[AW] is slightly different for empty path. |
Hirokazu, the patch looks fine, please apply to 2.7 and 3k. I wouldn't backport it to 2.6/3.0, since it may break existing code. |
Committed in r72273(trunk) and r72274(py3k). |
Yes, I tried to run cmd.exe and I did: C:\> cd D:\foo os.listdir('D:') and os.listdir('E:') then listed the content of D:\foo Thanks Hirokazu for the patch. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: