Skip to content

Commit e8ca19c

Browse files
sethmlarsonpicnixzhugovk
committed
Address review comments
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent f381a5e commit e8ca19c

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

Doc/library/os.path.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ the :mod:`glob` module.)
117117
>>> os.path.commonpath(['/usr/lib', '/usr/local/lib'])
118118
'/usr'
119119

120-
.. versionchanged:: 3.15
121-
Deprecated in favor of :func:`os.path.commonpath` for path prefixes and
122-
:func:`string.commonprefix` for string prefixes.
123-
124120
.. versionchanged:: 3.6
125121
Accepts a :term:`path-like object`.
126122

123+
.. deprecated:: next
124+
Deprecated in favor of :func:`os.path.commonpath` for path prefixes and
125+
:func:`string.commonprefix` for string prefixes.
126+
127127

128128
.. function:: dirname(path, /)
129129

Doc/library/string.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,9 @@ Helper functions
994994
.. function:: commonprefix(list, /)
995995

996996
Return the longest string prefix (taken character-by-character) that is a
997-
prefix of all string in *list*. If *list* is empty, return the empty string
998-
(``''``).
997+
prefix of all the strings in *list*. If *list* is empty, return the empty
998+
string (``''``).
999999

1000-
.. versionadded:: 3.15
1000+
.. versionadded:: next
10011001

10021002
Moved to the :mod:`string` module from the :mod:`os.path` module.

Lib/genericpath.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def commonprefix(m, /):
107107
"Given a list of pathnames, returns the longest common leading component"
108108
import warnings
109109
warnings.warn('os.path.commonprefix() is deprecated. Use '
110-
'os.path.commonpath() or string.commonprefix() instead.',
110+
'os.path.commonpath() for longest path prefix, or '
111+
'string.commonprefix() for longest string prefix.',
111112
category=DeprecationWarning,
112113
stacklevel=2)
113114
import string

Lib/string/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def capwords(s, sep=None):
4949

5050

5151
def commonprefix(m, /):
52-
"Given a list of strings, returns the longest common leading component"
53-
if not m: return ''
52+
"""Given a list of strings, returns the longest common leading component."""
53+
if not m:
54+
return ''
5455
# Note that previously this function was in the 'os.path' module, hence the
5556
# handling for paths. Maintain compatibility so users have a 1-to-1 drop-in.
5657
# Some people pass in a list of pathname parts to operate in an OS-agnostic

0 commit comments

Comments
 (0)