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
os.listdir(): inconsistent behavior with trailing spaces #43418
Comments
I've noticed some inconsistent behavior around Take this example code: import os
import tempfile
tmpdir = tempfile.mkdtemp()
newdir = os.path.join(tmpdir, " collect dir ")
os.mkdir(newdir)
print os.path.exists(newdir)
print os.listdir(newdir) If I run this code on Windows 2000 Pro using Python True It seems to me that if os.path.exists() tells me that |
Logged In: YES Since Python only calls the underlying Win32 function |
I agree with the fact that this inconsistent behaviour is disturbing. Example: open the idle, Traceback (most recent call last):
File "<pyshell#36>", line 1, in -toplevel-
os.listdir('lib ')
WindowsError: [Errno 3] Le chemin d'accès spécifié est introuvable: 'lib /*.*' os.stat('lib ') works ... I disagree with the argument that since Windows is bugged then Python is bugged too. I imagine that this is located in nt builtin module. Jerrykhan |
Would it be appropriate to make a comment about this Windows bug in both os.stat and os.path.exists documentation? I just stumbled upon it independently (both Win7 and 10, both Py 2.7 and 3.6) with nearly the same incantation that Kenneth reported over 10 years ago (exists check success, followed by scandir failure). [My workaround was to append os.sep to the directory spec: Clearly this behavior is not going away, so it should at least be mentioned somewhere more prominently than on a decade old BPO item... |
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: