[Python-Dev] pathlib - current status of discussions (original) (raw)
Nikolaus Rath Nikolaus at rath.org
Wed Apr 13 22:57:57 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, Ethan Furman <ethan at stoneleaf.us> wrote:
On 04/13/2016 03:45 PM, Nikolaus Rath 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. Yes, it is intentional. The second approach assumes fspath can only contain str, so there is no point in checking it for bytes.
Either I haven't understood your answer, or you haven't understood my question. I'm concerned about this case:
class Special(bytes): def fspath(self): return 'str-val' obj = Special('bytes-val', 'utf8') path_obj = fspath(obj, allow_bytes=True)
With #2, path_obj == 'bytes-val'. With #3, path_obj == 'str-val'.
I would expect that fspath(obj, allow_bytes=True) == 'str-val' (after all, it's allow_bytes, not require_bytes). Bu
Best, -Nikolaus
-- GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
»Time flies like an arrow, fruit flies like a Banana.«
- 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 ]