karan/joe

Incorrect output on broken pipe

jakubtuchol opened this issue · 0 comments

I'm currently running joe-0.0.6. When you pipe joe to a command that doesn't exist, you get the following behavior:

$ joe java | hello
-bash: hello: command not found
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

I looked into this behavior, and it turns out to be a bug in the Python 2.7 interpreter: the interpreter is not reporting an exception when failing to flush stdout. More about this can be found here and here.

I believe this behavior can be fixed by simply adding sys.stdout.flush() to the bottom of the main method.