[ python-Bugs-1502805 ] 'with' sometimes eats exceptions

SourceForge.net noreply at sourceforge.net
Thu Jun 8 16:50:45 CEST 2006


Bugs item #1502805, was opened at 2006-06-08 10:53
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1502805&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
>Status: Closed
>Resolution: Fixed
Priority: 6
Submitted By: Armin Rigo (arigo)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'with' sometimes eats exceptions

Initial Comment:
The 'with' statement eats some execeptions,
in a pattern that I haven't been able to
understand quite precisely:

>>> with os.popen('ls', 'r') as f:
...     print 'hi'
...     print 1/0
...
hi
ls: broken pipe
>>> 

----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2006-06-08 14:50

Message:
Logged In: YES 
user_id=849994

Good spotting! Fixed in rev. 46751.

----------------------------------------------------------------------

Comment By: Žiga Seilnacht (zseil)
Date: 2006-06-08 13:32

Message:
Logged In: YES 
user_id=1326842

The bug is in the file.__exit__ method. This method is
just an alias for file.close(), with METH_VARARGS instead
of METH_NOARGS as flags. It should be instead a method
that requires three parameters, closes the file and
returns a false value if those parameters were not None
or if something went wrong while closing the file.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1502805&group_id=5470


More information about the Python-bugs-list mailing list