New submission from Jeffrey Yasskin <[email protected]>:
There's an obscure bug in sys.exc_info after a yield statement.
def test():
def raising_generator():
try:
raise IndexError("inner exception")
except IndexError:
yield 3
# Here, sys.exc_info() ought to refer to the inner
# exception, but instead it refers to the outer one.
try:
raise ValueError("outer exception")
except ValueError:
for i in raising_generator(): pass
sys.exc_info gets reset even if there's no outer exception.
The attached (failing) patch highlights this problem, and tests other
sys.exc_info behavior around function calls.
----------
components: Interpreter Core
files: exc_info.patch
keywords: patch
messages: 87452
nosy: collinwinter, jyasskin
priority: low
severity: normal
stage: needs patch
status: open
title: sys.exc_info leaks into a generator
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1
Added file: http://bugs.python.org/file13927/exc_info.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue5970>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com