Nick Coghlan added the comment:

Oh, that's quite neat. Because of the way _GeneratorContextManager works, the 
context is actually already set correctly on the thrown exceptions, but 
ExitStack is assuming it will be wrong.

This means _fix_exception (part of ExitStack.__exit__) ends up setting the 
first exception's context to itself while handling the second exception, which 
then creates an infinite loop when attempting to handle the third exception. 
Hence why three is the magic number :)

The existing tests didn't pick this up, because they just used callbacks for 
simplicity, and hence the context was wrong as expected.

Commit incoming.

----------

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

Reply via email to