8000 Issue #29197: Removed deprecated function ntpath.splitunc(). · python/cpython@9ed707e · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ed707e

Browse files
Issue #29197: Removed deprecated function ntpath.splitunc().
1 parent 4f76fb1 commit 9ed707e

File tree

5 files changed

+9
-61
lines changed

5 files changed

+9
-61
lines changed

Doc/library/os.path.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -453,19 +453,6 @@ the :mod:`glob` module.)
453453
Accepts a :term:`path-like object`.
454454

455455

456-
.. function:: splitunc(path)
457-
458-
.. deprecated:: 3.1
459-
Use *splitdrive* instead.
460-
461-
Split the pathname *path* into a pair ``(unc, rest)`` so that *unc* is the UNC
462-
mount point (such as ``r'\\host\mount'``), if present, and *rest* the rest of
463-
the path (such as ``r'\path\file.ext'``). For paths containing drive letters,
464-
*unc* will always be the empty string.
465-
466-
Availability: Windows.
467-
468-
469456
.. data:: supports_unicode_filenames
470457

471458
``True`` if arbitrary Unicode strings can be used as file names (within limitations

Doc/whatsnew/3.7.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ API and Feature Removals
142142
* Removed support of the *exclude* argument in :meth:`tarfile.TarFile.add`.
143143
Use the *filter* argument instead.
144144

145+
* The ``splitunc()`` function in the :mod:`ntpath` module was deprecated in
146+
Python 3.1, and has now been removed. Use the :func:`~os.path.splitdrive`
147+
function instead.
148+
145149

146150
Porting to Python 3.7
147151
=====================

Lib/ntpath.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"basename","dirname","commonprefix","getsize","getmtime",
1616
"getatime","getctime", "islink","exists","lexists","isdir","isfile",
1717
"ismount", "expanduser","expandvars","normpath","abspath",
18-
"splitunc","curdir","pardir","sep","pathsep","defpath","altsep",
18+
"curdir","pardir","sep","pathsep","defpath","altsep",
1919
"extsep","devnull","realpath","supports_unicode_filenames","relpath",
2020
"samefile", "sameopenfile", "samestat", "commonpath"]
2121

@@ -169,28 +169,6 @@ def splitdrive(p):
169169
return p[:0], p
170170

171171

172-
# Parse UNC paths
173-
def splitunc(p):
174-
"""Deprecated since Python 3.1. Please use splitdrive() instead;
175-
it now handles UNC paths.
176-
177-
Split a pathname into UNC mount point and relative path specifiers.
178-
179-
Return a 2-tuple (unc, rest); either part may be empty.
180-
If unc is not empty, it has the form '//host/mount' (or similar
181-
using backslashes). unc+rest is always the input path.
182-
Paths containing drive letters never have a UNC part.
183-
"""
184-
import warnings
185-
warnings.warn("ntpath.splitunc is deprecated, use ntpath.splitdrive instead",
186-
DeprecationWarning, 2)
187-
drive, path = splitdrive(p)
188-
if len(drive) == 2:
189-
# Drive letter present
190-
return p[:0], p
191-
return drive, path
192-
193-
194172
# Split a path in head (everything up to the last '/') and tail (the
195173
# rest). After the trailing '/' is stripped, the invariant
196174
# join(head, tail) == p holds.

Lib/test/test_ntpath.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,6 @@ def test_splitdrive(self):
7272
self.assertEqual(ntpath.splitdrive('//conky/MOUNTPOİNT/foo/bar'),
7373
('//conky/MOUNTPOİNT', '/foo/bar'))
7474

75-
def test_splitunc(self):
76-
with self.assertWarns(DeprecationWarning):
77-
ntpath.splitunc('')
78-
with support.check_warnings(('', DeprecationWarning)):
79-
tester('ntpath.splitunc("c:\\foo\\bar")',
80-
('', 'c:\\foo\\bar'))
81-
tester('ntpath.splitunc("c:/foo/bar")',
82-
('', 'c:/foo/bar'))
83-
tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")',
84-
('\\\\conky\\mountpoint', '\\foo\\bar'))
85-
tester('ntpath.splitunc("//conky/mountpoint/foo/bar")',
86-
('//conky/mountpoint', '/foo/bar'))
87-
tester('ntpath.splitunc("\\\\\\conky\\mountpoint\\foo\\bar")',
88-
('', '\\\\\\conky\\mountpoint\\foo\\bar'))
89-
tester('ntpath.splitunc("///conky/mountpoint/foo/bar")',
90-
('', '///conky/mountpoint/foo/bar'))
91-
tester('ntpath.splitunc("\\\\conky\\\\mountpoint\\foo\\bar")',
92-
('', '\\\\conky\\\\mountpoint\\foo\\bar'))
93-
tester('ntpath.splitunc("//conky//mountpoint/foo/bar")',
94-
('', '//conky//mountpoint/foo/bar'))
95-
self.assertEqual(ntpath.splitunc('//conky/MOUNTPOİNT/foo/bar'),
96-
('//conky/MOUNTPOİNT', '/foo/bar'))
97-
9875
def test_split(self):
9976
tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar'))
10077
tester('ntpath.split("\\\\conky\\mountpoint\\foo\\bar")',
@@ -449,7 +426,7 @@ def test_ismount(self):
449426

450427
class NtCommonTest(test_genericpath.CommonTest, unittest.TestCase):
451428
pathmodule = ntpath
452-
attributes = ['relpath', 'splitunc']
429+
attributes = ['relpath']
453430

454431

455432
class PathLikeTests(unittest.TestCase):

Misc/NEWS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ Core and Builtins
212212
Library
213213
-------
214214

215-
- Issue #29210: Removed support of deprecated argument "exclude" in
215+
- Issue #29197: Removed deprecated function ntpath.splitunc().
216+
217+
- Issue #29210: Removed support of deprecated argument "exclude" in
216218
tarfile.TarFile.add().
217219

218220
- Issue #29219: Fixed infinite recursion in the repr of uninitialized

0 commit comments

Comments
 (0)
0