8000 gh-117074: Update Traversable.joinpath docs to the 3.11+ protocol (GH… · python/cpython@e569f91 · GitHub
[go: up one dir, main page]

Skip to content

Commit e569f91

Browse files
authored
gh-117074: Update Traversable.joinpath docs to the 3.11+ protocol (GH-117113)
1 parent 52f5b7f commit e569f91

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

Doc/library/importlib.resources.abc.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,35 @@
109109

110110
Return True if self is a file.
111111

112-
.. abstractmethod:: joinpath(child)
112+
.. abstractmethod:: joinpath(*pathsegments)
113113

114-
Return Traversable child in self.
114+
Traverse directories according to *pathsegments* and return
115+
the result as :class:`!Traversable`.
116+
117+
Each *pathsegments* argument may contain multiple names separated by
118+
forward slashes (``/``, ``posixpath.sep`` ).
119+
For example, the following are equivalent::
120+
121+
files.joinpath('subdir', 'subsuddir', 'file.txt')
122+
files.joinpath('subdir/subsuddir/file.txt')
123+
124+
Note that some :class:`!Traversable` implementations
125+
might not be updated to the latest version of the protocol.
126+
For compatibility with such implementations, provide a single argument
127+
without path separators to each call to ``joinpath``. For example::
128+
129+
files.joinpath('subdir').joinpath('subsubdir').joinpath('file.txt')
130+
131+
.. versionchanged:: 3.11
132+
133+
``joinpath`` accepts multiple *pathsegments*, and these segments
134+
may contain forward slashes as path separators.
135+
Previously, only a single *child* argument was accepted.
115136

116137
.. abstractmethod:: __truediv__(child)
117138

118139
Return Traversable child in self.
140+
Equivalent to ``joinpath(child)``.
119141

120142
.. abstractmethod:: open(mode='r', *args, **kwargs)
121143

0 commit comments

Comments
 (0)
0