New submission from Jim Fulton <j...@zope.com>:

In python 2.7 a module can't be used as a context manager.

For example, given the module, t.py:

    def __enter__(*args):
        print 'enter', args

    def __exit__(*args):
        print 'exit', args

In Python 2.6:

    >>> import t
    >>> with t: pass
    ... 
    enter ()
    exit (None, None, None)

In Python 2.7:

    >>> import t
    >>> with t: pass
    ... 
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: __exit__

----------
components: Interpreter Core
messages: 109920
nosy: j1m
priority: normal
severity: normal
status: open
title: Modules no longer usable as context managers
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9220>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to