[Zope-Checkins] CVS: Zope/lib/python/App - Common.py:1.13

Toby Dickenson tdickenson@geminidataloggers.com
Wed, 17 Apr 2002 12:23:20 -0400


Update of /cvs-repository/Zope/lib/python/App
In directory cvs.zope.org:/tmp/cvs-serv23056

Modified Files:
	Common.py 
Log Message:
Fixed two bugs in realpath:
1. Out by one error where it would not unravel links in the final path element
2. Correct handling of link destinations which are relative paths
This needs a unit test, but doesnt yet have one.



=== Zope/lib/python/App/Common.py 1.12 => 1.13 ===
         changed = 0
         i = 1
-        while not changed and i < orig_len:
+        while not changed and i <= orig_len:
             head = path_list[:i]
             tail = path_list[i:]
             head_s = os.sep.join(head)
             tail_s = os.sep.join(tail)
             if os.path.islink(head_s):
-                head_s = os.readlink(head_s)
+                head_s = os.path.join(os.sep.join(head[:-1]),
+                                      os.readlink(head_s))
                 path_list = head_s.split(os.sep)
                 path_list.extend(tail)
                 p = os.sep.join(path_list)