os.listdir() bug in WinXp. Calling with empty string

Terry Reedy tjreedy at udel.edu
Sun Oct 5 12:05:41 EDT 2003


"John Roth" <newsgroups at jhrothjr.com> wrote in message
news:vo004qejvqfcaa at news.supernews.com...
>
> "Terry Reedy" <tjreedy at udel.edu> wrote in message
> > It seems to be defined as whatever the os does with empty strings,
> > which is not much more useful.  You could open SF bug report
listing
> > various XP, W98, Linux behaviors and suggest that listdir def be
> > changed to 'if path: current behaviour; else: raise exception'.
>
> I'd like to argue *against* raising an exception. We had a long
> discussion on this exact point on the XP list a while ago, with
> Ron Jeffries holding out for the position that if you can define
> a useful behavior for a corner case, then you should do so
> rather than raising an exception. The least surprising behavior
> here is to simply list the current directory. In other words,
> a null string would be equivalent to a string containing a single
> dot.

You are suggesting to insert "if not path: path= '.'"  I would
consider that to also improve over the current situation.  You can add
a note to Hannu's bug report to make sure this is considered by
whoever picks it up.

Terry J. Reedy






More information about the Python-list mailing list