[issue9220] Modules no longer usable as context managers

2010-07-10 Thread Jim Fulton
Jim Fulton added the comment: On Sat, Jul 10, 2010 at 4:08 PM, Éric Araujo wrote: > > Éric Araujo added the comment: > > Confirmed: http://docs.python.org/reference/datamodel#specialnames > Closing. Sorry! (BTW, using import hackery and a custom module type, you > could achieve your goal.) Y

[issue9220] Modules no longer usable as context managers

2010-07-10 Thread Benjamin Peterson
Benjamin Peterson added the comment: Yes, definitely. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:/

[issue9220] Modules no longer usable as context managers

2010-07-10 Thread Mark Dickinson
Mark Dickinson added the comment: Just for the record, this changed with the introduction of the SETUP_WITH opcode in r72912. Perhaps Benjamin can confirm that the behaviour change was deliberate? -- nosy: +benjamin.peterson, mark.dickinson ___ Py

[issue9220] Modules no longer usable as context managers

2010-07-10 Thread Éric Araujo
Éric Araujo added the comment: Confirmed: http://docs.python.org/reference/datamodel#specialnames Closing. Sorry! (BTW, using import hackery and a custom module type, you could achieve your goal.) -- resolution: -> invalid stage: -> committed/rejected status: open -> closed

[issue9220] Modules no longer usable as context managers

2010-07-10 Thread Éric Araujo
Éric Araujo added the comment: IIUC, magic methods are looked up on the object’s class, not in the object’s __dict__. This behavior in 2.6 seems like a bug to me. I-tried-to-add-__call__-to-a-module-once-ly yours -- nosy: +merwok ___ Python tracker

[issue9220] Modules no longer usable as context managers

2010-07-10 Thread Jim Fulton
New submission from Jim Fulton : 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