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

Guido van Rossum guido at python.org
Tue Sep 30 16:26:13 CEST 2008


On Tue, Sep 30, 2008 at 3:52 AM, Hrvoje Nikšić <hrvoje.niksic at avl.com> wrote:
> On Tue, 2008-09-30 at 19:45 +1000, Nick Coghlan wrote:
>> To my mind, there are two kinds of app in the world when it comes to
>> file paths:
>> 1) "Normal" apps (e.g. a word processor), that are only interested in
>> files with sane, well-formed file names that can be properly decoded to
>> Unicode with the filesystem encoding identified by Python. If there is
>> invalid data on the filesystem, they don't care and don't want to see it
>> or have to deal with it.
>
> 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) and it shouldn't be crippled by the mere *presence* of
an undecodable file in a directory. I can think of lots of apps that
have a sufficiently small or homogeneous audience (e.g. lots of
in-house apps) that they don't need to care about such files, and
these shouldn't break when they are used in the vicinity of an
undecodable filename -- it's enough if they just ignore it.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list