[Checkins] SVN: zope.security/trunk/src/zope/security/decorator.py Fixed a complicated bug where DecoratedSecurityCheckerDescriptor made

Albertas Agejevas alga at pov.lt
Fri Mar 20 15:17:09 EDT 2009


Log message for revision 98289:
  Fixed a complicated bug where DecoratedSecurityCheckerDescriptor made
  Checker.proxy barf if the proxied object was a new-style exception (in
  Python 2.5). 
  
  This was the underlying problem in https://bugs.launchpad.net/zope3/+bug/251848 .
  

Changed:
  U   zope.security/trunk/src/zope/security/decorator.py

-=-
Modified: zope.security/trunk/src/zope/security/decorator.py
===================================================================
--- zope.security/trunk/src/zope/security/decorator.py	2009-03-20 19:16:22 UTC (rev 98288)
+++ zope.security/trunk/src/zope/security/decorator.py	2009-03-20 19:17:08 UTC (rev 98289)
@@ -160,7 +160,15 @@
 
     the decorator doesn't have a checker:
 
-      >>> wrapper.__Security_checker__ is None
+      >>> wrapper.__Security_checker__
+      Traceback (most recent call last):
+        ...
+      AttributeError: 'Foo' has no attribute '__Security_checker__'
+
+    __Security_checker__ cannot be None, otherwise Checker.proxy blows
+    up:
+
+      >>> checker.proxy(wrapper) is wrapper
       True
 
     """
@@ -176,7 +184,11 @@
                 if checker is None:
                     checker = selectChecker(proxied_object)
             wrapper_checker = selectChecker(inst)
-            if wrapper_checker is None:
+            if wrapper_checker is None and checker is None:
+                raise AttributeError("%r has no attribute %r" %
+                                     (proxied_object.__class__.__name__,
+                                      '__Security_checker__'))
+            elif wrapper_checker is None:
                 return checker
             elif checker is None:
                 return wrapper_checker



More information about the Checkins mailing list