You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os.listdir on empty strings. Inconsistent behaviour. #39373
Activity
hannukoo commentedon Oct 5, 2003
Behaviour tested in Python 2.3 (final) and 2.3.2 (final).
os.listdir('') and os.listdir(u'') have very different
behaviour across different OSes:
WinXP/WinNT:
os.listdir('') -- current dir (e.g. c:\\python)
os.listdir(u'') -- root dir (e.g. c:\\)
Win98
os.listdir('') -- root dir
os.listdir(u'') -- root dir
Redhat Linux 9.0
os.listdir('') -- OSError
os.listdir(u'') -- OSError
Particularly weird is the WinXP/WinNT behaviour that is
different between unicode and normal strings.
Suggestion for fix: Make os.listdir for empty strings
always
raise an exception or always list the current working
directory.
rhettinger commentedon Oct 28, 2003
Logged In: YES
user_id=80475
Confirmed for WinME/98. Also, the behavior changed from
Py2.2 where on WinME/98, it returned the root directory.
rhettinger commentedon Oct 28, 2003
Logged In: YES
user_id=80475
Just, I believe this was your change.
jvr commentedon Oct 28, 2003
Logged In: YES
user_id=92689
I didn't touch the Win side of os.listdir() (it already supported
unicode strings), so I'm pretty sure it isn't.
amauryfa commentedon Dec 4, 2008
This may become important when switching to python 3.0...
When passed str(''), FindFirstFileA is called with "*.*".
But when passed unicode(''), FindFirstFileW is called with L"\\*.*" !!!
Attached patch fixes (and tests) the problem. It was developed on 3.0,
but applies on all versions.
benjaminp commentedon May 29, 2009
Superseded by bpo-5913.