This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eljay451
Recipients eljay451
Date 2008-03-14.18:43:43
SpamBayes Score 0.033013918
Marked as misclassified No
Message-id <1205520225.21.0.16693669718.issue2289@psf.upfronthosting.co.za>
In-reply-to
Content
I found a bug (or at least a shortcoming) in Python's os.path.normpath routine.

It overly normalizes, at least for Unix and Unix-like systems (including Mac), and 
Windows.

Example:

x = os.path.join(".", "dog", "..", "cupcake.txt")
print x
x = os.path.normpath(x)
print x

If say "dog" is a symlink (any flavor of Unix (including OS X), or Win), there is a 
difference between ./dog/../cupcake.txt and ./cupcake.txt.

In the OS, if dog is a symlink to fire/fly, the .. resolves relative to fire/fly.

It should be safe to normalize this:
././././././././cupcake.txt --> ./cupcake.txt

It should be safe to normalize this:
.////////////////cupcake.txt --> ./cupcake.txt

But this is not safe to normalize:
./x/../x/../x/../cupcake.txt --> ./cupcake.txt

For example, if the directories look like this:
./cupcake.txt
./over/yonder/back/cupcake.txt
./x --> over/there
./over/there
./over/x --> yonder/aways
./over/yonder/aways
./over/yonder/x --> back/again
./over/yonder/back/again

./cupcake.txt refers to first cupcake.
./x/../x/../x/../cupcake.txt refers to the second cupcake.

The os.path.realpath does the resolve, but sometimes the path-in-hand is for some 
arbitrary path, and not necessarily one on the local system, or if on the local 
files system may be relative based off from a different cwd.
History
Date User Action Args
2008-03-14 18:43:45eljay451setspambayes_score: 0.0330139 -> 0.033013918
recipients: + eljay451
2008-03-14 18:43:45eljay451setspambayes_score: 0.0330139 -> 0.0330139
messageid: <1205520225.21.0.16693669718.issue2289@psf.upfronthosting.co.za>
2008-03-14 18:43:44eljay451linkissue2289 messages
2008-03-14 18:43:43eljay451create