[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__” instead of “type(mgr).__enter__(mgr)”, which might be 
misleading.

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11428
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 343, the evaluation of mgr.__exit__, or the evaluation of with 
mgr: pass must be broken, though I'm no longer sure which.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11428
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 
appears to be a bug.

--
components: Interpreter Core
messages: 130231
nosy: benrg
priority: normal
severity: normal
status: open
title: with statement looks up __exit__ incorrectly
type: behavior
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11428
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11428
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com