[Python-checkins] CVS: python/dist/src/Lib posixpath.py,1.39,1.40
M.-A. Lemburg
lemburg@users.sourceforge.net
Mon, 29 Jan 2001 03:29:46 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv14010
Modified Files:
posixpath.py
Log Message:
Fixed posixpath.normpath() to respect two leading slashes, but
turn three or more into a single slash. (This is in sync with POSIX
susv2 according to Fredrik.)
Index: posixpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -r1.39 -r1.40
*** posixpath.py 2001/01/15 00:50:52 1.39
--- posixpath.py 2001/01/29 11:29:44 1.40
***************
*** 344,348 ****
if path == '':
return '.'
! initial_slash = (path[0] == '/')
comps = path.split('/')
new_comps = []
--- 344,353 ----
if path == '':
return '.'
! initial_slashes = path.startswith('/')
! # POSIX allows one or two initial slashes, but treats three or more
! # as single slash.
! if (initial_slashes and
! path.startswith('//') and not path.startswith('///')):
! initial_slashes = 2
comps = path.split('/')
new_comps = []
***************
*** 350,354 ****
if comp in ('', '.'):
continue
! if (comp != '..' or (not initial_slash and not new_comps) or
(new_comps and new_comps[-1] == '..')):
new_comps.append(comp)
--- 355,359 ----
if comp in ('', '.'):
continue
! if (comp != '..' or (not initial_slashes and not new_comps) or
(new_comps and new_comps[-1] == '..')):
new_comps.append(comp)
***************
*** 357,362 ****
comps = new_comps
path = '/'.join(comps)
! if initial_slash:
! path = '/' + path
return path or '.'
--- 362,367 ----
comps = new_comps
path = '/'.join(comps)
! if initial_slashes:
! path = '/'*initial_slashes + path
return path or '.'