[Python-bugs-list] [Bug #113894] os.listdir gives fails on Win32 platforms
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 8 Sep 2000 08:55:04 -0700
Bug #113894, was updated on 2000-Sep-08 08:55
Here is a current snapshot of the bug.
Project: Python
Category: Modules
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Summary: os.listdir gives fails on Win32 platforms
Details: On windows NT the os.listdir() function doesn't correctly handle paths containing a drive specification, but no other directory spec. It incorrectly references the root directory on the specified drive rather than the current directory.
For example these two calls should return the same thing (the actual output has been slightly trimmed):
>>> import os
>>> os.listdir('c:')
['3DCube', 'Acrobat3', 'ADOBEAPP', ...]
>>> os.listdir('c:.')
['Capture', 'Catalog', ...]
The same problem shows up in os.glob, for example os.glob('d:*.py') will expand to all .py files in the root of drive d rather than the current directory.
One possible fix is that in posixmodule.c, function posix_listdir, the lines:
strcpy(namebuf, name);
if (namebuf[len-1] != '/' && namebuf[len-1] != '\\')
namebuf[len++] = '/';
strcpy(namebuf + len, "*.*");
should read:
strcpy(namebuf, name);
if (namebuf[len-1] != '/' && namebuf[len-1] != '\\' && namebuf[len-1] != ':')
namebuf[len++] = '/';
strcpy(namebuf + len, "*.*");
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=113894&group_id=5470