New submission from Hagen Fürstenau:

The following code will sometimes warn about an ignored TypeError('catching 
classes that do not inherit from BaseException is not allowed',) on termination:


class MyException(Exception):
    pass

def gen():
    try:
        yield
    except MyException:
        pass

g = gen()
next(g)


Of course, MyException inherits from Exception, so there should be no problem.

Apparently, MyException gets destroyed before the generator object (at least 
sometimes, presumably depending on the hash randomization seed), and the 
destructor of the generator object then complains because there is no 
MyException any more. At least that's my explanation of this, without having 
digged into the code.

----------
components: Interpreter Core
messages: 190365
nosy: hagen
priority: normal
severity: normal
status: open
title: except-clause with own exception class inside generator can lead to 
confusing warning on termination
type: behavior
versions: Python 3.3

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

Reply via email to