On 10/23/05, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> Actually, you've just pointed out a new complication introduced by having
> __context__.  The return value of __context__ is supposed to have an
> __enter__ and an __exit__.  Is it a type error if it doesn't?  How do we
> handle that, exactly?

Of course it's an error! The translation in the PEP should make that
quite clear (there's no testing for whether __context__, __enter__
and/or __exit__ exist before they are called). It would be an
AttributeError.

> That is, assuming generators don't have enter/exit/context methods, then
> the above code is broken because its __context__ returns an object without
> enter/exit, sort of like an __iter__ that returns something without a 
> 'next()'.

Right. That was my point. Nick's worried about undecorated __context__
because he wants to endow generators with a different default
__context__. I say no to both proposals and the worries cancel each
other out. EIBTI.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
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

Reply via email to