Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _get_bothseps(path):
LOCALE_NAME_INVARIANT as _LOCALE_NAME_INVARIANT,
LCMAP_LOWERCASE as _LCMAP_LOWERCASE)

def normcase(s):
def normcase(s, /):
"""Normalize case of pathname.

Makes all characters lowercase and all slashes into backslashes.
Expand All @@ -66,7 +66,7 @@ def normcase(s):
_LCMAP_LOWERCASE,
s.replace('/', '\\'))
except ImportError:
def normcase(s):
def normcase(s, /):
"""Normalize case of pathname.

Makes all characters lowercase and all slashes into backslashes.
Expand All @@ -77,7 +77,7 @@ def normcase(s):
return s.replace('/', '\\').lower()


def isabs(s):
def isabs(s, /):
"""Test whether a path is absolute"""
s = os.fspath(s)
if isinstance(s, bytes):
Expand Down Expand Up @@ -143,7 +143,7 @@ def join(path, *paths):
# Split a path in a drive specification (a drive letter followed by a
# colon) and the path specification.
# It is always true that drivespec + pathspec == p
def splitdrive(p):
def splitdrive(p, /):
"""Split a pathname into drive/UNC sharepoint and relative path specifiers.
Returns a 2-tuple (drive_or_unc, path); either part may be empty.

Expand All @@ -169,7 +169,7 @@ def splitdrive(p):
try:
from nt import _path_splitroot_ex as splitroot
except ImportError:
def splitroot(p):
def splitroot(p, /):
"""Split a pathname into drive, root and tail.

The tail contains anything after the root."""
Expand Down Expand Up @@ -219,7 +219,7 @@ def splitroot(p):
# join(head, tail) == p holds.
# The resulting head won't end in '/' unless it is the root.

def split(p):
def split(p, /):
"""Split a pathname.

Return tuple (head, tail) where tail is everything after the final slash.
Expand All @@ -240,7 +240,7 @@ def split(p):
# pathname component; the root is everything before that.
# It is always true that root + ext == p.

def splitext(p):
def splitext(p, /):
p = os.fspath(p)
if isinstance(p, bytes):
return genericpath._splitext(p, b'\\', b'/', b'.')
Expand All @@ -251,14 +251,14 @@ def splitext(p):

# Return the tail (basename) part of a path.

def basename(p):
def basename(p, /):
"""Returns the final component of a pathname"""
return split(p)[1]


# Return the head (dirname) part of a path.

def dirname(p):
def dirname(p, /):
"""Returns the directory component of a pathname"""
return split(p)[0]

Expand Down
16 changes: 8 additions & 8 deletions Lib/posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def _get_sep(path):
# normalizations (such as optimizing '../' away) are not allowed
# (another function should be defined to do that).

def normcase(s):
def normcase(s, /):
"""Normalize case of pathname. Has no effect under Posix"""
return os.fspath(s)


# Return whether a path is absolute.
# Trivial in Posix, harder on the Mac or MS-DOS.

def isabs(s):
def isabs(s, /):
"""Test whether a path is absolute"""
s = os.fspath(s)
sep = _get_sep(s)
Expand Down Expand Up @@ -97,7 +97,7 @@ def join(a, *p):
# '/' in the path, head will be empty.
# Trailing '/'es are stripped from head unless it is the root.

def split(p):
def split(p, /):
"""Split a pathname. Returns tuple "(head, tail)" where "tail" is
everything after the final slash. Either part may be empty."""
p = os.fspath(p)
Expand All @@ -114,7 +114,7 @@ def split(p):
# pathname component; the root is everything before that.
# It is always true that root + ext == p.

def splitext(p):
def splitext(p, /):
p = os.fspath(p)
if isinstance(p, bytes):
sep = b'/'
Expand All @@ -128,7 +128,7 @@ def splitext(p):
# Split a pathname into a drive specification and the rest of the
# path. Useful on DOS/Windows/NT; on Unix, the drive is always empty.

def splitdrive(p):
def splitdrive(p, /):
"""Split a pathname into drive and path. On Posix, drive is always
empty."""
p = os.fspath(p)
Expand All @@ -138,7 +138,7 @@ def splitdrive(p):
try:
from posix import _path_splitroot_ex as splitroot
except ImportError:
def splitroot(p):
def splitroot(p, /):
"""Split a pathname into drive, root and tail.

The tail contains anything after the root."""
Expand All @@ -163,7 +163,7 @@ def splitroot(p):

# Return the tail (basename) part of a path, same as split(path)[1].

def basename(p):
def basename(p, /):
"""Returns the final component of a pathname"""
p = os.fspath(p)
sep = _get_sep(p)
Expand All @@ -173,7 +173,7 @@ def basename(p):

# Return the head (dirname) part of a path, same as split(path)[0].

def dirname(p):
def dirname(p, /):
"""Returns the directory component of a pathname"""
p = os.fspath(p)
sep = _get_sep(p)
Expand Down
84 changes: 9 additions & 75 deletions Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5535,15 +5535,16 @@ os__path_lexists_impl(PyObject *module, path_t *path)
/*[clinic input]
os._path_isdir -> bool

s as path: path_t(allow_fd=True, suppress_value_error=True)
s as path: path_t(allow_fd=True, suppress_value_error=True),
/

Return true if the pathname refers to an existing directory.

[clinic start generated code]*/

static int
os__path_isdir_impl(PyObject *module, path_t *path)
/*[clinic end generated code: output=d5786196f9e2fa7a input=132a3b5301aecf79]*/
/*[clinic end generated code: output=d5786196f9e2fa7a input=6d3c18234e720b19]*/
{
return _testFileType(path, PY_IFDIR);
}
Expand Down Expand Up @@ -5612,7 +5613,8 @@ os__path_isjunction_impl(PyObject *module, path_t *path)
/*[clinic input]
os._path_splitroot_ex

p as path: path_t(make_wide=True, nonstrict=True)
p as path: path_t(make_wide=True, nonstrict=True),
/

Split a pathname into drive, root and tail.

Expand All @@ -5621,7 +5623,7 @@ The tail contains anything after the root.

static PyObject *
os__path_splitroot_ex_impl(PyObject *module, path_t *path)
/*[clinic end generated code: output=4b0072b6cdf4b611 input=4556b615c7cc13f2]*/
/*[clinic end generated code: output=4b0072b6cdf4b611 input=ccd3dfece9b2d79a]*/
{
Py_ssize_t drvsize, rootsize;
PyObject *drv = NULL, *root = NULL, *tail = NULL, *result = NULL;
Expand Down
Loading