[Python-Dev] pathlib - current status of discussions (original) (raw)
Random832 random832 at fastmail.us
Wed Apr 13 19:55:32 EDT 2016
- Previous message (by thread): [Python-Dev] pathlib - current status of discussions
- Next message (by thread): [Python-Dev] pathlib - current status of discussions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Apr 13, 2016 19:06, Brett Cannon <brett at python.org> wrote:
On Wed, 13 Apr 2016 at 15:46 Nikolaus Rath <Nikolaus at rath.org> wrote:
When passing an object that is of type str and has a fspath attribute, all approaches return the value of fspath().
However, when passing something of type bytes, the second approach returns the object, while the third returns the value of fspath(). Is this intentional? I think a fspath attribute should always be preferred. It's very much intentional. If we define fspath() to only return strings but still want to minimize boilerplate of allowing bytes to simply pass through without checking a path argument to see if it is bytes then approach #2 is warranted. But if fspath() can return bytes then approach #3 allows for it.
Er, the difference comes in when the object passed to os.fspath is a subclass of bytes that, itself, has a fspath method (which may return a str). It's unlikely to occur in the wild, but is a semantic difference between this case and all other objects with fspath methods.
- Previous message (by thread): [Python-Dev] pathlib - current status of discussions
- Next message (by thread): [Python-Dev] pathlib - current status of discussions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]