[Python-Dev] Patch for an initial support of bytes filename in Python3
glyph at divmod.com
glyph at divmod.com
Tue Sep 30 15:21:51 CEST 2008
On 12:47 am, victor.stinner at haypocalc.com wrote:
This is the most sane contribution I've seen so far :).
>See attached patch: python3_bytes_filename.patch
>
>Using the patch, you will get:
>- open() support bytes
>- listdir(unicode) -> only unicode, *skip* invalid filenames
> (as asked by Guido)
Forgive me for being a bit dense, but I couldn't find this hunk in the
patch. Do I understand properly that (listdir(bytes) -> bytes)?
If so, this seems basically sane to me, since it provides text behavior
where possible and allows more sophisticated filesystem wrappers (i.e.
Twisted's FilePath, Will McGugan's "FS") to do more tricky things,
separating filenames for display to the user and filenames for exchange
with the FS.
>- remove os.getcwdu()
>- create os.getcwdb() -> bytes
>- glob.glob() support bytes
>- fnmatch.filter() support bytes
>- posixpath.join() and posixpath.split() support bytes
It sounds like maybe there should be some 2to3 fixers in here somewhere,
too? Not necessarily as part of this patch, but somewhere related? I
don't know what they would do, but it does seem quite likely that code
which was previously correct under 2.6 (using bytes) would suddenly be
mixing bytes and unicode with these APIs.
More information about the Python-Dev
mailing list