[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Traversing - __init__.py:1.9

Steve Alexander steve@cat-box.net
Tue, 26 Nov 2002 08:14:51 -0500


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

Modified Files:
	__init__.py 
Log Message:
Fixed bugs in the locationToTuple and locationToUnicode convenience
functions.
Refactored tests for these functions for greater clarity and greater
coverage.


=== Zope3/lib/python/Zope/App/Traversing/__init__.py 1.8 => 1.9 ===
--- Zope3/lib/python/Zope/App/Traversing/__init__.py:1.8	Tue Jul 16 19:41:18 2002
+++ Zope3/lib/python/Zope/App/Traversing/__init__.py	Tue Nov 26 08:14:49 2002
@@ -142,7 +142,7 @@
         raise ValueError, \
             "location %s must be a string or a tuple of strings." % (location,)
         
-    if t[-1] == u'':  # matches '' or u''
+    if len(t) > 1 and t[-1] == u'':  # matches '' or u''
         raise ValueError, \
             "location tuple %s must not end with empty string." % (t,)
     # don't usually need this, so just an assertion rather than a value error
@@ -160,6 +160,8 @@
         raise ValueError, "location must be non-empty."
     if isinstance(location, tuple):
         u = u'/'.join(location)
+        if not u:  # special case for u''
+            return u'/'
     elif isinstance(location, StringTypes):
         u = unicode(location)
     else: