[Python-Dev] Filename as byte string in python 2.6 or 3.0?

Hrvoje Nikšić hrvoje.niksic at avl.com
Tue Sep 30 16:39:45 CEST 2008

On Tue, 2008-09-30 at 07:26 -0700, Guido van Rossum wrote:
> > I am not convinced that a word processor can just ignore files with
> > (what it thinks are) undecodable file names.  In countries with a
> > history of incompatible national encodings, such file names crop up very
> > often, sometimes as a natural consequence of data migrating from older
> > systems to newer ones.  You can and do encounter "invalid" file names in
> > the filesystems of mainstream users even without them using buggy or
> > obsolete software.
> This is a quality of implementation issue. Either the word processor
> is written to support "undecodable" files, or it isn't. If it isn't,
> there's nothing that can be done about it (short of buying another
> wordprocessor)

I agree with this.  I just believe the underlying python APIs shouldn't
make it impossible (or unnecessarily hard) for the word processor to
implement showing of files with undecodable names.

For example, implementing os.listdir to return the file names as Unicode
subclasses with ability to access the underlying bytes (automatically
recognized by open and friends) sounds like a good compromise that
allows the word processor to both have the cake and eat it.

More information about the Python-Dev mailing list