Log message for revision 127292: - fixed TypeError handling in unrestrictedTraverse
Changed: U Zope/branches/2.13/doc/CHANGES.rst UU Zope/branches/2.13/src/OFS/Traversable.py UU Zope/branches/2.13/src/OFS/tests/testTraverse.py -=- Modified: Zope/branches/2.13/doc/CHANGES.rst =================================================================== --- Zope/branches/2.13/doc/CHANGES.rst 2012-07-10 06:29:24 UTC (rev 127291) +++ Zope/branches/2.13/doc/CHANGES.rst 2012-07-10 06:48:11 UTC (rev 127292) @@ -8,6 +8,8 @@ 2.13.16 (unreleased) -------------------- +- OFS: Fixed TypeError handling in unrestrictedTraverse. + - Updated distributions: - AccessControl = 2.13.8 Modified: Zope/branches/2.13/src/OFS/Traversable.py =================================================================== --- Zope/branches/2.13/src/OFS/Traversable.py 2012-07-10 06:29:24 UTC (rev 127291) +++ Zope/branches/2.13/src/OFS/Traversable.py 2012-07-10 06:48:11 UTC (rev 127292) @@ -260,9 +260,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/branches/2.13/src/OFS/Traversable.py ___________________________________________________________________ Deleted: svn:keywords - Id Modified: Zope/branches/2.13/src/OFS/tests/testTraverse.py =================================================================== --- Zope/branches/2.13/src/OFS/tests/testTraverse.py 2012-07-10 06:29:24 UTC (rev 127291) +++ Zope/branches/2.13/src/OFS/tests/testTraverse.py 2012-07-10 06:48:11 UTC (rev 127292) @@ -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/branches/2.13/src/OFS/tests/testTraverse.py ___________________________________________________________________ Deleted: svn:keywords - Id _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins