[issue20317] ExitStack hang if enough nested exceptions

Nick Coghlan report at bugs.python.org
Wed Jan 22 13:39:05 CET 2014


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 <report at bugs.python.org>
<http://bugs.python.org/issue20317>
_______________________________________


More information about the Python-bugs-list mailing list