Bugs item #1495754, was opened at 2006-05-26 23:28 Message generated for change (Comment added) made by jerrykhan You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1495754&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Windows Group: Python 2.4 Status: Closed Resolution: Wont Fix Priority: 5 Private: No Submitted By: Kenneth J. Pronovici (pronovic) Assigned to: Nobody/Anonymous (nobody) Summary: os.listdir(): inconsistent behavior with trailing spaces Initial Comment: I've noticed some inconsistent behavior around os.listdir() and paths that contain trailing spaces on the Windows platform. 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 2.4.2, I get this: True [Errno 3] The system cannot find the path specified: 'c:\\docume~1\\a0clu0~1.bcb\\locals~1 \\temp\\tmpfd7j3t\\ collect dir /*.*' It seems to me that if os.path.exists() tells me that a file or directory exists, that os.listdir() should be able to operate on it. ---------------------------------------------------------------------- Comment By: JerryKhan (jerrykhan) Date: 2007-03-27 13:41 Message: Logged In: YES user_id=867168 Originator: NO I agree with the fact that this inconsistent behaviour is disturbing. I tried it with a simple example "lib ", if it exists, we must be able to browse it. Example: open the idle, import os os.path.exists("lib ") ==> True os.path.listdir('lib ') 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 ... os.stat(' lib') does not work (that ok to me) I disagree with the argument that since Windows is bugged then Python is bugged too. It should be possible to rightstrip the folder name before asking for the resolution of abspath/the_dir_with_space_at_the_end /*.* Or to deactivate the rightstriping done on the stat builtin function. I imagine that this is located in nt builtin module. I have done it in my own program .. but this should be coded in interfaces modules. Jerrykhan ---------------------------------------------------------------------- Comment By: Georg Brandl (gbrandl) Date: 2006-05-29 22:59 Message: Logged In: YES user_id=849994 Since Python only calls the underlying Win32 function FindFirstFile, I think there can nothing be done since that function seems to be buggy in this respect. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1495754&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com