[Python-Dev] File system path PEP, part 2

Joseph Martinot-Lagarde contrebasse at gmail.com
Fri May 13 10:23:09 EDT 2016


> - there is no os function that returns "str or bytes, I don't 
>   care which". (If you really need that, call __fspath__ directly.)

os.fspath() in the PEP works when given str or bytes directly, but those
don't have a __fspath__ method, so directly calling the dunder method is not
equivalent to calling os.fspath(). The whole point of having os.fspath() is
to pass str or paths (or bytes) and get an appropriate object for lew-level
functions.



More information about the Python-Dev mailing list