Exceção TypeErro aviso às vezes mostrado, às vezes não quando usando o método throw do gerador
Existe este código:
class MyException(Exception):
pass
def gen():
for i in range(3):
try:
yield i
except MyException:
print("MyException!")
a = gen()
next(a)
a.throw(MyException)
Executando este código:
$ python3.3 main.py
MyException!
$ python3.3 main.py
MyException!
Exception TypeError: TypeError('catching classes that do not inherit from BaseException is not allowed',) in <generator object gen at 0xb712efa4> ignored
$ python3.3 main.py
MyException!
$ python3.3 main.py
MyException!
$ python3.3 main.py
MyException!
Exception TypeError: TypeError('catching classes that do not inherit from BaseException is not allowed',) in <generator object gen at 0xb714afa4> ignored
A coisa que eu não entendo é por que às vezes é impresso issoException TypeError
Aviso. Há algo de errado com exceção personalizada?