Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b08388d

Browse files
committed
Issue #27182: Document os.PathLike.
Part of PEP 519.
1 parent 516f546 commit b08388d

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Doc/library/functions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,9 @@ are always available. They are listed here in alphabetical order.
10771077
.. versionchanged:: 3.5
10781078
The ``'namereplace'`` error handler was added.
10791079

1080+
.. versionchanged:: 3.6
1081+
Support added to accept objects implementing :class:`os.PathLike`.
1082+
10801083
.. function:: ord(c)
10811084

10821085
Given a string representing one Unicode character, return an integer

Doc/library/os.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ process and user.
175175

176176
.. versionadded:: 3.2
177177

178+
.. versionchanged:: 3.6
179+
Support added to accept objects implementing :class:`os.PathLike`.
180+
178181

179182
.. function:: fsdecode(filename)
180183

@@ -185,6 +188,9 @@ process and user.
185188

186189
.. versionadded:: 3.2
187190

191+
.. versionchanged:: 3.6
192+
Support added to accept objects implementing :class:`os.PathLike`.
193+
188194

189195
.. function:: fspath(path)
190196

@@ -195,6 +201,21 @@ process and user.
195201
(which is represented by :class:`os.PathLike`). All other types raise a
196202
:exc:`TypeError`.
197203

204+
.. versionadded:: 3.6
205+
206+
207+
.. class:: PathLike
208+
209+
An :term:`abstract base class` for objects representing a file system path,
210+
e.g. :class:`pathlib.PurePath`.
211+
212+
.. abstractmethod:: __fspath__()
213+
214+
Return the file system path representation of the object.
215+
216+
The method should only return a :class:`str` or :class:`bytes` object,
217+
with the preference being for :class:`str`.
218+
198219

199220
.. function:: getenv(key, default=None)
200221

0 commit comments

Comments
 (0)