[Python-checkins] python/dist/src/Lib posixpath.py,1.70,1.71

jlgijsbers at users.sourceforge.net jlgijsbers at users.sourceforge.net
Sat Aug 14 17:01:55 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27018/Lib

Modified Files:
	posixpath.py 
Log Message:
bug #990669: os.path.realpath() will resolve symlinks before normalizing the
path, as normalizing the path may alter the meaning of the path if it contains
symlinks.

Also add tests for infinite symlink loops and parent symlinks that need to be
resolved.


Index: posixpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v
retrieving revision 1.70
retrieving revision 1.71
diff -C2 -d -r1.70 -r1.71
*** posixpath.py	2 Aug 2004 14:54:16 -0000	1.70
--- posixpath.py	14 Aug 2004 15:01:53 -0000	1.71
***************
*** 401,407 ****
      """Return the canonical path of the specified filename, eliminating any
  symbolic links encountered in the path."""
!     filename = abspath(filename)
! 
!     bits = ['/'] + filename.split('/')[1:]
      for i in range(2, len(bits)+1):
          component = join(*bits[0:i])
--- 401,409 ----
      """Return the canonical path of the specified filename, eliminating any
  symbolic links encountered in the path."""
!     if isabs(filename):
!         bits = ['/'] + filename.split('/')[1:]
!     else:
!         bits = filename.split('/')
!         
      for i in range(2, len(bits)+1):
          component = join(*bits[0:i])
***************
*** 411,421 ****
              if resolved is None:
                  # Infinite loop -- return original component + rest of the path
!                 return join(*([component] + bits[i:]))
              else:
                  newpath = join(*([resolved] + bits[i:]))
!                 return realpath(newpath)
! 
!     return filename
  
  
  def _resolve_link(path):
--- 413,423 ----
              if resolved is None:
                  # Infinite loop -- return original component + rest of the path
!                 return abspath(join(*([component] + bits[i:])))
              else:
                  newpath = join(*([resolved] + bits[i:]))
!                 return realpath(newpath)        
  
+     return abspath(filename)
+     
  
  def _resolve_link(path):



More information about the Python-checkins mailing list