homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 'with' sometimes eats exceptions
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: arigo, georg.brandl, zseil
Priority: high Keywords:

Created on 2006年06月08日 10:53 by arigo, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (3)
msg28745 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006年06月08日 10:53
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
>>> 
msg28746 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006年06月08日 13:32
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.
msg28747 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006年06月08日 14:50
Logged In: YES 
user_id=849994
Good spotting! Fixed in rev. 46751.
History
Date User Action Args
2022年04月11日 14:56:17adminsetgithub: 43473
2006年06月08日 10:53:16arigocreate

AltStyle によって変換されたページ (->オリジナル) /