stdio_mgr leaves REPL in munged state after exception inside context
bskinn opened this issue · 0 comments
bskinn commented
Demo, from the newly merged master @ 48527c6:
>>> from stdio_mgr import stdio_mgr
>>> with stdio_mgr(close=False) as (i, o, e):
... 1/0
...
>>> 1/0
>>> i
>>> o
>>> e
>>> dir(o)
>>> 1 + '1'
>>> import sys
>>> sys.stdout = sys.__stdout__
>>> sys.stderr = sys.__stderr__
>>> print('abd')
abd
>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
>>>
The problem predates the recent changes toward v2.0. With v1.0.1 checked out:
>>> from stdio_mgr import stdio_mgr
>>> with stdio_mgr() as (i, o, e):
... 1/0
...
>>> i
>>> o
>>> e
>>> 1/0
>>> print('abcd')
>>>
It would seem that the "__exit__
" code after the yield
in the decorated stdio_mgr
function is not actually being run? Perhaps it is very important to implement #10??