Dmitry Vasiliev wrote: > Philipp von Weitershausen wrote: >> Hi there, >> >> I've filed an issue in the collector outlining a problem with old style >> classes and TALES traversal: http://www.zope.org/Collectors/Zope3-dev/635 >> >> In particular, I'm looking for comments on problem #2. > > PEP-3100 suggest "just call the object and catch the exception" instead > of use "callable()". So maybe we can write: > > try: > ob() > except: > pass > return ob > > Unfortunately exceptions still will be masked.
Yes. I honestly have no clue what the authors of this part of PEP3000 were thinking. Even if you only catch AttributeError, you'll never be sure the AttributeError is from the missing __call__ or from inside it. callable() isn't even deprecated yet, so if it solves our problem, we can use it IMO. Note that Zope 3 deliberately doesn't use it because of the proxy problem. Zope 2 works around that by stripping proxies/wrappers first (ob.aq_base). Perhaps Zope3 should do that as well. Would callable(removeAllProxies(obj)) be harmful in any way if you end up calling the proxied obj() anyway? Philipp _______________________________________________ Zope3-dev mailing list [email protected] Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
