A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-April/144100.html below:

[Python-Dev] pathlib - current status of discussions

[Python-Dev] pathlib - current status of discussionsEthan Furman ethan at stoneleaf.us
Wed Apr 13 23:14:44 EDT 2016
On 04/13/2016 07:57 PM, Nikolaus Rath wrote:
> On Apr 13 2016, Ethan Furman 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 misunderstood your question.  That is... an interesting case.  ;)

--
~Ethan~

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4