[Zope-Checkins] CVS: Zope/lib/python/AccessControl - cAccessControl.c:1.10.12.6

Shane Hathaway shane@digicool.com
Thu, 18 Oct 2001 15:58:13 -0400


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

Modified Files:
      Tag: cAccessControl-review-branch
	cAccessControl.c 
Log Message:
- Changed calls to PyErr_Occurred() to PyErr_ExceptionMatches(), so that
  subclassed exceptions will work.

- ZopeSecurityPolicy should sometimes raise Unauthorized when proxy roles
  limit access.  Fixed.


=== Zope/lib/python/AccessControl/cAccessControl.c 1.10.12.5 => 1.10.12.6 ===
 				roles = aq_acquire(container, __roles__);
 				if (roles == NULL) {
-                                  if (PyErr_Occurred() == PyExc_AttributeError)
+                                  if (PyErr_ExceptionMatches(
+                                      PyExc_AttributeError))
                                     {
                                         PyErr_Clear();
 				        if (containerbase != accessedbase) {
@@ -660,7 +661,7 @@
             { /* Error */
               PyObject *m, *t, *v, *tb;
 
-              if (PyErr_Occurred() != PyExc_TypeError)
+              if (!PyErr_ExceptionMatches(PyExc_TypeError))
                 goto err;
               PyErr_Fetch(&t, &v, &tb);
               
@@ -785,7 +786,15 @@
                           }
                       }
                     Py_DECREF(proxy_roles);
-                    if (contains >= 0) rval = PyInt_FromLong(contains);
+
+                    if (contains > 0)
+                      rval = PyInt_FromLong(contains);
+                    else if (contains == 0) {
+                      if (accessedbase == containerbase) {
+                        unauthErr(name, value);
+                      }
+                      else rval = PyInt_FromLong(contains);
+                    }
                     goto err;
                   }
                 else 
@@ -800,7 +809,7 @@
         if (user) ASSIGN(user, PyObject_GetAttr(user, allowed_str));
         if (user == NULL)
           {
-            if (PyErr_Occurred() == PyExc_AttributeError)
+            if (PyErr_ExceptionMatches(PyExc_AttributeError))
               PyErr_Clear();
             else
               goto err;