On 12.05.2016 18:24, Guido van Rossum wrote:
def fspath(p: Union[str, bytes, PathLike]) -> Union[str, bytes]:
    if isinstance(p, (str, bytes)):
        return p
    try:
        return p.__fspath__
    except AttributeError:
        raise TypeError(...)

@Brett
Would you think it makes sense to swap the str/bytes check and the __fspath__ check?


I just thought of a class subclassing str/bytes and defines __fspath__. Its __fspath__ method would be ignored currently.


Best,
Sven
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to