[Python-checkins] CVS: python/dist/src/Lib ntpath.py,1.36,1.37
Tim Peters
tim_one@users.sourceforge.net
2001年7月19日 10:18:20 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv19604/python/dist/src/Lib
Modified Files:
ntpath.py
Log Message:
SF bug #44271: os.path.expanduser problem w/o HOME set.
This is a Windows-specific glitch that's really due to that, e.g.,
ntpath.join("c:", "/abc") returned "/abc" instead of "c:/abc". Made
join smarter.
Bugfix candidate.
Index: ntpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** ntpath.py 2001年05月15日 15:23:01 1.36
--- ntpath.py 2001年07月19日 17:18:18 1.37
***************
*** 43,52 ****
path = a
for b in p:
! if isabs(b):
! path = b
! elif path == '' or path[-1:] in '/\\:':
! path = path + b
! else:
! path = path + "\\" + b
return path
--- 43,62 ----
path = a
for b in p:
! # If path is a raw drive letter (e.g. "C:"), and b doesn't start
! # with a drive letter, path+b is correct, and regardless of whether
! # b is absolute on its own.
! if len(path) == 2 and path[-1] == ":" and splitdrive(b)[0] == "":
! pass
!
! # In any other case, if b is absolute it wipes out the path so far.
! elif isabs(b) or path == "":
! path = ""
!
! # Else make sure a separator appears between the pieces.
! elif path[-1:] not in "/\\":
! b = "\\" + b
!
! path += b
!
return path