[Python-Dev] os.normpath may change the meaning of the path if it contains symbolic links?

Nir Soffer nirs at freeshell.org
Fri Dec 2 22:56:15 CET 2005


I'm working on  
<https://sourceforge.net/tracker/index.php? 
func=detail&aid=1239890&group_id=5470&atid=305470>

My patch uses os.path.normpath to simplify the path sent to makedirs as  
first step. This eliminates the need to check for os.currdir or other  
special case, because normpath already handle all those ugly spacial  
cases (and hopefully tested). And of course eliminate possible  
pointless system calls.

For example (on Mac OS X):

 >>> os.path.normpath('a/./////b/c')
'a/b/c'
 >>> os.path.normpath('a/b/c/.')
'a/b/c'
 >>> os.path.normpath('./a/b')
'a/b'
 >>> os.path.normpath('a/b/////')
'a/b'

However, I found this alarming note in the docs:

normpath(path)
	...
	"It should be understood that this may change the meaning of the path  
if it contains symbolic links!"

The function docstring does not contain this note:

	"""Normalize path, eliminating double slashes, etc."""

And finally, there is no test for this symbolic link problem.

Anyone has a clue about this?


Best Regards,

Nir Soffer



More information about the Python-Dev mailing list