Update of /cvs-repository/Packages/Interface In directory cvs.zope.org:/tmp/cvs-serv32028/lib/python/Interface
Modified Files: Tag: tseaver-hasattr_geddon-branch Implements.py Verify.py _InterfaceClass.py Log Message: - Removed all uses of the 'hasattr' builtin from the core, where the object being tested derives (or might) from Persistent. XXX: currently, this branch imports a 'safe_hasattr' from ZODB.utils, which adds a dependency on ZODB for some packages; we probably need a better location, and perhas a C implementation? === Packages/Interface/Implements.py 1.4.12.1 => 1.4.12.1.32.1 === --- Packages/Interface/Implements.py:1.4.12.1 Mon Oct 20 17:41:31 2003 +++ Packages/Interface/Implements.py Sat May 28 20:41:30 2005 @@ -22,6 +22,7 @@ from Verify import verifyClass from _InterfaceClass import Interface as InterfaceClass from types import TupleType, ClassType, StringType +from ZODB.utils import safe_hasattr # Special value indicating the object supports # what its class supports. @@ -34,9 +35,9 @@ def getImplements(object): t = type(object) if t in ClassTypes: - if hasattr(object, '__class_implements__'): + if safe_hasattr(object, '__class_implements__'): return object.__class_implements__ - elif hasattr(object, '__implements__'): + elif safe_hasattr(object, '__implements__'): return object.__implements__ return _typeImplements.get(t, None) === Packages/Interface/Verify.py 1.4 => 1.4.94.1 === --- Packages/Interface/Verify.py:1.4 Mon Nov 11 14:53:16 2002 +++ Packages/Interface/Verify.py Sat May 28 20:41:30 2005 @@ -16,6 +16,7 @@ from Exceptions import BrokenMethodImplementation from types import FunctionType from Method import fromMethod, fromFunction +from ZODB.utils import safe_hasattr from _object import MethodTypes def _verify(iface, candidate, tentative=0, vtype=None): @@ -45,7 +46,7 @@ raise DoesNotImplement(iface) for n, d in iface.namesAndDescriptions(1): - if not hasattr(candidate, n): + if not safe_hasattr(candidate, n): raise BrokenImplementation(iface, n) attr = getattr(candidate, n) === Packages/Interface/_InterfaceClass.py 1.6 => 1.6.132.1 === --- Packages/Interface/_InterfaceClass.py:1.6 Wed Aug 14 17:35:32 2002 +++ Packages/Interface/_InterfaceClass.py Sat May 28 20:41:30 2005 @@ -23,6 +23,7 @@ from Attribute import Attribute from types import FunctionType import Exceptions +from ZODB.utils import safe_hasattr from _Element import Element from _object import isInstance @@ -177,7 +178,8 @@ def deferred(self): """Return a defered class corresponding to the interface """ - if hasattr(self, "_deferred"): return self._deferred + if safe_hasattr(self, "_deferred"): + return self._deferred klass={} exec "class %s: pass" % self.__name__ in klass _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins