Skip to content

Commit

Permalink
Fixed some self-introduced im_self problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees committed Feb 1, 2017
1 parent de3aa2e commit 4c42f3e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AccessControl/ImplPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def verifyAcquisitionContext(user, object, object_roles=None):
# This is a strange rule, though
# it doesn't cause any security holes. SDH
return 1
if hasattr(object, 'im_self') and object.im_self is not None:
if getattr(object, 'im_self', None) is not None:
# This is a method. Grab its self.
object=object.__self__
if not aq_inContextOf(object, ucontext, 1):
Expand Down
2 changes: 1 addition & 1 deletion src/AccessControl/Permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def getRoles(self, default=_marker):
if name:
if hasattr(obj, name):
attr = getattr(obj, name)
if hasattr(attr, 'im_self') and attr.im_self is not None:
if getattr(attr, 'im_self', None) is not None:
attr = attr.__self__
if hasattr(attr, '__dict__'):
attr = attr.__dict__
Expand Down
2 changes: 1 addition & 1 deletion src/AccessControl/userfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _getobcontext(self, v, request):
if innerparent is not None:
# this is not a method, we needn't treat it specially
c = innerparent
elif hasattr(v, 'im_self') and object.im_self is not None:
if getattr(v, 'im_self', None) is not None:
# this is a method, we need to treat it specially
c = v.__self__
c = getattr(v, 'aq_inner', v)
Expand Down
6 changes: 3 additions & 3 deletions src/AccessControl/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def getRolesInContext(self, object):
if parent is not None:
object = parent
continue
if hasattr(object, 'im_self') and object.im_self is not None:
if getattr(object, 'im_self', None) is not None:
object=object.__self__
object=getattr(object, 'aq_inner', object)
continue
Expand Down Expand Up @@ -140,7 +140,7 @@ def _check_context(self, object):
if context is not None:
if object is None:
return 1
if hasattr(object, 'im_self') and object.im_self is not None:
if getattr(object, 'im_self', None) is not None:
# This is a method. Grab its self.
object = object.__self__
return aq_inContextOf(object, context, 1)
Expand Down Expand Up @@ -202,7 +202,7 @@ def allowed(self, object, object_roles=None):
parents.add(parent)
inner_obj = parent
continue
if hasattr(inner_obj, 'im_self') and object.im_self is not None:
if getattr(inner_obj, 'im_self', None) is not None:
inner_obj = inner_obj.__self__
inner_obj = getattr(inner_obj, 'aq_inner', inner_obj)
continue
Expand Down

0 comments on commit 4c42f3e

Please sign in to comment.