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

Victor Stinner victor.stinner at haypocalc.com
Mon Sep 29 13:37:29 CEST 2008


Le Monday 29 September 2008 12:50:03 Ulrich Eckhardt, vous avez écrit :
> (...) uses an ASCII mapping where possible and codepoints from the 
> "Private Use Area" (PUA) of Unicode for the non-decodable bytes.

That sounds to me like a very *ugly* hack.

It remembers me my proposition to create an object have the API of both bytes 
and str types: str(<Filename object>) = human representation of the filename, 
bytes(<Filename>) = original bytes filename. As I wrote in the first email of 
this thread, it's not a good idea to mix bytes and characters.

Why trying to convert bytes to characters when the operating system expects 
bytes? To get the best compatibility, we have to use the native types, at 
least when str(filename, fs_encoding) fails and/or str(filename, 
fs_encoding).encode(fs_encoding) != filename.

-- 
Victor Stinner aka haypo
http://www.haypocalc.com/blog/


More information about the Python-Dev mailing list