[issue11428] with statement looks up __exit__ incorrectly

2011-03-11 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: After a quick perusal of the PEP, there are no wrong definitions of context managers (IOW they define methods in a class, not attribute on an object), but the pseudo-code explaining how the statement works use things like “mgr.__enter__”

[issue11428] with statement looks up __exit__ incorrectly

2011-03-07 Thread benrg
benrg benrud...@gmail.com added the comment: But when I translate my example according to PEP 343, it works (i.e., doesn't raise an exception) in 3.2, and PEP 343 says [t]he details of the above translation are intended to prescribe the exact semantics. So I think that at least one of PEP

[issue11428] with statement looks up __exit__ incorrectly

2011-03-07 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- assignee: - benjamin.peterson nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11428 ___

[issue11428] with statement looks up __exit__ incorrectly

2011-03-07 Thread Benjamin Peterson
Benjamin Peterson benja...@python.org added the comment: Well, the pep is wrong, too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11428 ___

[issue11428] with statement looks up __exit__ incorrectly

2011-03-06 Thread benrg
New submission from benrg benrud...@gmail.com: class MakeContextHandler: def __init__(self, enter, exit): self.__enter__ = enter self.__exit__ = exit with MakeContextHandler(lambda: None, lambda *e: None): pass In 3.1.3 this worked; in 3.2 it raises AttributeError('__exit__'), which

[issue11428] with statement looks up __exit__ incorrectly

2011-03-06 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: The bug is actually in 3.1 and fixed in 3.2: special methods (those with __underscore__ names) are supposed to be looked up on the class, not the instance. -- nosy: +georg.brandl resolution: - invalid status: open - closed