[Python-Dev] Pathlib enhancements - acceptable inputs and outputs for __fspath__ and os.fspath()
Victor Stinner
victor.stinner at gmail.com
Mon Apr 11 16:42:20 EDT 2016
2016-04-11 21:00 GMT+02:00 Brett Cannon <brett at python.org>:
> I'm -0 on allowing __fspath__ to return bytes, but we can see what others
> think.
With the PEP 383, a bytes filename can be stored as str using the
surrogateescape error handler. So DirEntry can convert a bytes path to
str using os.fsdecode().
A "byte string" is unclear in Python. There is the immutable "bytes"
type. But there is also the mutable "bytearray" type. And the buffer
protocol which can have different shapes.
I like the idea of a simple protocol: only allow a single type, str.
Victor
More information about the Python-Dev
mailing list