New submission from Ronnie Maor <ronnie.m...@gmail.com>:

Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def coroutine():
...     try:
...             raise Exception('bla')
...     except:
...             yield 'foo'
...             raise
...
>>> for _ in coroutine():
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 6, in coroutine
TypeError: exceptions must be classes or instances, not NoneType

Seems that yielding in the except clause makes python forget the current 
exception, so a bar "raise" statement raises None, instead of the 
original exception.
changing except to except Exception,e: and raise to raise e throws the 
original exception, but then the original stack trace is lost.

----------
components: Interpreter Core
messages: 96812
nosy: ronniemaor
severity: normal
status: open
title: yield in except clause causes exception context to be lost
type: behavior
versions: Python 2.6

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

Reply via email to