[issue25782] CPython hangs on error __context__ set to the error itself

Nick Coghlan report at bugs.python.org
Mon Jun 13 19:03:57 EDT 2016


Nick Coghlan added the comment:

Thanks Serhiy. I've attached a new file (issue27122_broken_cm.py) with a context manager that is deliberately buggy in the same way as contextlib._GeneratorContextManager is currently, so the new test can be made independent of #27122 being fixed (Greg Smith has a pending patch to make that CM well behaved again, which would currently lead to your new test passing for the wrong reasons)

issue27122_broken_cm.py also shows why I think "make it work" is the right answer here - the odd context chaining is tolerated in the case where the interpreter is implicitly setting the exception context, so I believe it should also be tolerated when ExitStack sets the context explicitly. If we "do the right thing" (where "right" = "the same as what the interpreter does") in the setter, then not only ExitStack, but anyone else setting __context__ should automatically benefit from the adjustment.

----------
Added file: http://bugs.python.org/file43382/issue27122_broken_cm.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25782>
_______________________________________


More information about the Python-bugs-list mailing list