Skip to content

Match docstring and args for posixpath.join and ntpath.join #104478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
8 changes: 7 additions & 1 deletion Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def isabs(s):

# Join two (or more) paths.
def join(path, *paths):
"""Join two or more pathname components, inserting '\\' as needed.
If any component is an absolute path with a root, all previous path
components will be discarded. If any component is an absolute path without
a root, all previous path components except for the root will be discarded.
An empty last part will result in a path that ends with a separator."""
path = os.fspath(path)
if isinstance(path, bytes):
sep = b'\\'
Expand All @@ -116,7 +121,8 @@ def join(path, *paths):
colon = ':'
try:
if not paths:
path[:0] + sep #23780: Ensure compatible data type even if p is null.
# bpo-23780: Ensure compatible data type even if paths is empty.
path[:0] + sep
result_drive, result_root, result_path = splitroot(path)
for p in map(os.fspath, paths):
p_drive, p_root, p_path = splitroot(p)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a docstring for :func:`os.path.join` on Windows.