os.listdir() bug in WinXp. Calling with empty string
Hannu Kankaanp??
hanzspam at yahoo.com.au
Sat Oct 4 11:36:21 EDT 2003
This may be a bug or simply a strange result of undefined
behaviour, but this is what I get with Python 2.3.2 on
Windows XP:
>>> import os
>>> os.listdir('')
[ filenames in the current directory, e.g. c:\python\ ]
>>> os.listdir(u'')
[ filenames in the drive's root directory, e.g. c:\ ]
Maybe os.listdir() behaviour is undefined for empty strings,
but the different behaviour between unicode and normal
strings surprised me. If calling it with an empty string is
illegal, it should throw an exception instead of doing
weird things.
This works fine, though:
>>> os.listdir('.')
[ filenames in the current directory, e.g. c:\python\ ]
>>> os.listdir(u'.')
[ filenames in the current directory, e.g. c:\python\ ]
More information about the Python-list
mailing list