[New-bugs-announce] [issue11428] with statement looks up __exit__ incorrectly

benrg report at bugs.python.org
Mon Mar 7 08:19:17 CET 2011

New submission from benrg <benrudiak at 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 <report at bugs.python.org>

More information about the New-bugs-announce mailing list