diff options
author | Brett Cannon <brett@python.org> | 2016-06-24 19:03:43 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2016-06-24 19:03:43 (GMT) |
commit | c78ca1e044b7ca4c1764bb3670196e72351d4467 (patch) | |
tree | 3435d7babe85991192e645d12c9ec2b24b4de04f /Doc/library/os.rst | |
parent | 19b2a53a82c8f4d179efdc39fb39f766191cac2b (diff) | |
download | cpython-c78ca1e044b7ca4c1764bb3670196e72351d4467.zip cpython-c78ca1e044b7ca4c1764bb3670196e72351d4467.tar.gz cpython-c78ca1e044b7ca4c1764bb3670196e72351d4467.tar.bz2 |
Issue #27186: Update os.fspath()/PyOS_FSPath() to check the return
type of __fspath__().
As part of this change, also make sure that the pure Python
implementation of os.fspath() is tested.
Diffstat (limited to 'Doc/library/os.rst')
-rw-r--r-- | Doc/library/os.rst | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 465b218..0346cc2 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -179,7 +179,8 @@ process and user. .. versionadded:: 3.2 .. versionchanged:: 3.6 - Support added to accept objects implementing :class:`os.PathLike`. + Support added to accept objects implementing the :class:`os.PathLike` + interface. .. function:: fsdecode(filename) @@ -192,17 +193,18 @@ process and user. .. versionadded:: 3.2 .. versionchanged:: 3.6 - Support added to accept objects implementing :class:`os.PathLike`. + Support added to accept objects implementing the :class:`os.PathLike` + interface. .. function:: fspath(path) Return the file system representation of the path. - If :class:`str` or :class:`bytes` is passed in, it is returned unchanged; - otherwise, the result of calling ``type(path).__fspath__`` is returned - (which is represented by :class:`os.PathLike`). All other types raise a - :exc:`TypeError`. + If :class:`str` or :class:`bytes` is passed in, it is returned unchanged. + Otherwise :meth:`~os.PathLike.__fspath__` is called and its value is + returned as long as it is a :class:`str` or :class:`bytes` object. + In all other cases, :exc:`TypeError` is raised. .. versionadded:: 3.6 |