[Zope-Checkins] SVN: Zope/trunk/src/OFS/ - fixed TypeError handling in unrestrictedTraverse
Yvo Schubbe
cvs-admin at zope.org
Tue Jul 10 06:48:52 UTC 2012
Log message for revision 127293:
- fixed TypeError handling in unrestrictedTraverse
Changed:
UU Zope/trunk/src/OFS/Traversable.py
UU Zope/trunk/src/OFS/tests/testTraverse.py
-=-
Modified: Zope/trunk/src/OFS/Traversable.py
===================================================================
--- Zope/trunk/src/OFS/Traversable.py 2012-07-10 06:48:11 UTC (rev 127292)
+++ Zope/trunk/src/OFS/Traversable.py 2012-07-10 06:48:48 UTC (rev 127293)
@@ -284,9 +284,10 @@
if isinstance(next, NullResource):
resource = next
raise KeyError(name)
- except AttributeError:
+ except (AttributeError, TypeError):
# Raise NotFound for easier debugging
# instead of AttributeError: __getitem__
+ # or TypeError: not subscriptable
raise NotFound(name)
if restricted and not validate(
obj, obj, None, next):
Property changes on: Zope/trunk/src/OFS/Traversable.py
___________________________________________________________________
Deleted: svn:keywords
- Id
Modified: Zope/trunk/src/OFS/tests/testTraverse.py
===================================================================
--- Zope/trunk/src/OFS/tests/testTraverse.py 2012-07-10 06:48:11 UTC (rev 127292)
+++ Zope/trunk/src/OFS/tests/testTraverse.py 2012-07-10 06:48:48 UTC (rev 127293)
@@ -402,6 +402,20 @@
self.assertEqual(
self.root.folder1.restrictedTraverse('stuff', 42), 42)
+ def testNotFoundIsRaised(self):
+ from OFS.SimpleItem import SimpleItem
+ from zExceptions import NotFound
+ from operator import getitem
+ self.folder1._setObject('foo', SimpleItem('foo'))
+ self.assertRaises(AttributeError, getitem, self.folder1.foo,
+ 'doesntexist')
+ self.assertRaises(NotFound, self.folder1.unrestrictedTraverse,
+ 'foo/doesntexist')
+ self.assertRaises(TypeError, getitem,
+ self.folder1.foo.isPrincipiaFolderish, 'doesntexist')
+ self.assertRaises(NotFound, self.folder1.unrestrictedTraverse,
+ 'foo/isPrincipiaFolderish/doesntexist')
+
def testDefaultValueWhenNotFound(self):
# Test that traversing to a non-existent object returns
# the default when provided
Property changes on: Zope/trunk/src/OFS/tests/testTraverse.py
___________________________________________________________________
Deleted: svn:keywords
- Id
More information about the Zope-Checkins
mailing list