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

Stephen J. Turnbull turnbull at sk.tsukuba.ac.jp
Wed Oct 1 16:10:51 CEST 2008


Antoine Pitrou writes:
 > Stephen J. Turnbull <stephen <at> xemacs.org> writes:
 > > 
 > > What makes you think the filenames are invalid?  The file*names* are
 > > probably perfectly valid in the intended encoding; they are simply
 > > invalid in the encoding that Python wants to apply.
 > 
 > Those filenames don't work today with Python 3, the problem is to
 > make them work.  Whether they are valid or not in a hypothetical
 > encoding is none of our business, if it's not the encoding we are
 > expecting.

It's usually not "hypothetical"; often, the user knows what it is.
Why not ask her?  That's what web browsers do, in effect, by providing
View as Charset commands.

The problem with the strategies that are being proposed is that this
is an application-level problem, not a Python-level problem.  Good web
browsers allow you to redisplay the document in a different encoding.
Python should make it possible to do the same, *if* the application
wants to.  It should also be possible for apps to do other things,
*if* they want to.  That means IMO that Python should limit itself to
caching the bytes (or equivalent hacky representation) somewhere that
apps that want to do something robust (including "ask the user" or
"automatically try a different guess" or "silently throw them away")
can find them.

Doing more that that is just asking for bug reports that can only be
closed as "wontfix" or "pebkac".


More information about the Python-3000 mailing list