Given the current semantics of PEP 343 and the following class: class null_context(object): def __context__(self): return self def __enter__(self): return self def __exit__(self, *exc_info): pass
Mistakenly writing: with null_context: # Oops, passed the class instead of an instance Would give a less than meaningful error message: TypeError: unbound method __context__() must be called with null_context instance as first argument (got nothing instead) It's the usual metaclass problem with invoking a slot (or slot equivalent) via "obj.__slot__()" rather than via "type(obj).__slot__(obj)" the way the underlying C code does. I think we need to fix the proposed semantics so that they access the slots via the type, rather than directly through the instance. Otherwise the slots for the with statement will behave strangely when compared to the slots for other magic methods. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ 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