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.
This commit is contained in:
Brett Cannon 2016-06-24 12:03:43 -07:00
parent 19b2a53a82
commit c78ca1e044
7 changed files with 101 additions and 71 deletions

View file

@ -10,8 +10,9 @@ Operating System Utilities
Return the file system representation for *path*. If the object is a
:class:`str` or :class:`bytes` object, then its reference count is
incremented. If the object implements the :class:`os.PathLike` interface,
then ``type(path).__fspath__()`` is returned. Otherwise :exc:`TypeError` is
raised and ``NULL`` is returned.
then :meth:`~os.PathLike.__fspath__` is returned as long as it is a
:class:`str` or :class:`bytes` object. Otherwise :exc:`TypeError` is raised
and ``NULL`` is returned.
.. versionadded:: 3.6