@@ -135,7 +135,7 @@ def splitdrive(p):
135135
136136
137137try :
138- from posix import _path_splitroot_ex
138+ from posix import _path_splitroot_ex as splitroot
139139except ImportError :
140140 def splitroot (p ):
141141 """Split a pathname into drive, root and tail. On Posix, drive is always
@@ -164,23 +164,7 @@ def splitroot(p):
164164 # Precisely two leading slashes, e.g.: '//foo'. Implementation defined per POSIX, see
165165 # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13
166166 return empty , p [:2 ], p [2 :]
167- else :
168- def splitroot (p ):
169- """Split a pathname into drive, root and tail. On Posix, drive is always
170- empty; the root may be empty, a single slash, or two slashes. The tail
171- contains anything after the root. For example:
172167
173- splitroot('foo/bar') == ('', '', 'foo/bar')
174- splitroot('/foo/bar') == ('', '/', 'foo/bar')
175- splitroot('//foo/bar') == ('', '//', 'foo/bar')
176- splitroot('///foo/bar') == ('', '/', '//foo/bar')
177- """
178- p = os .fspath (p )
179- if isinstance (p , bytes ):
180- # Optimisation: the drive is always empty
181- _ , root , tail = _path_splitroot_ex (os .fsdecode (p ))
182- return b'' , os .fsencode (root ), os .fsencode (tail )
183- return _path_splitroot_ex (p )
184168
185169
186170# Return the tail (basename) part of a path, same as split(path)[1].
@@ -366,7 +350,7 @@ def expandvars(path):
366350# if it contains symbolic links!
367351
368352try :
369- from posix import _path_normpath
353+ from posix import _path_normpath as normpath
370354
371355except ImportError :
372356 def normpath (path ):
@@ -397,14 +381,6 @@ def normpath(path):
397381 path = initial_slashes + sep .join (comps )
398382 return path or dot
399383
400- else :
401- def normpath (path ):
402- """Normalize path, eliminating double slashes, etc."""
403- path = os .fspath (path )
404- if isinstance (path , bytes ):
405- return os .fsencode (_path_normpath (os .fsdecode (path ))) or b"."
406- return _path_normpath (path ) or "."
407-
408384
409385def abspath (path ):
410386 """Return an absolute path."""
0 commit comments