At 10:13 PM 6/26/2006 -0700, Guido van Rossum wrote: >On 6/26/06, Greg Ewing <[EMAIL PROTECTED]> wrote: >>Phillip J. Eby wrote: >> >> > It's not inconsistent - isinstance() checks __class__ in *addition* to >> > type() in order to allow proxying tricks like lying about your >> > __class__. >> >>If this is a deliberate feature, it's a bit patchy, because >>it means the proxy can't lie about *not* being an instance >>of its real type. >> >>Perhaps Guido could clarify how much lying a proxy is >>supposed to be able to get away with? > >Sorry, I don't remember all the constraints. Read the code and weep. >This should be revisited for Py3k. The code became convoluted out of >some needs in Zope; I can't remember if it was Zope 2 or Zope 3 that >needed this (probably both) and I can't remember the specific >situation where it was needed.
It was Zope 3 security proxies, although *any* proxy type benefits. The idea was to make proxy objects be able to lie about their __class__ and be believed by isinstance(). However, there was no requirement that isinstance(ob, Proxy) return False, so that's not implemented. And lying about __bases__ appears to only be allowed for things that aren't types. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com