Serhiy Storchaka added the comment: I meant that C files stderr and stdout can be closed. Or it's file descriptors can be closed. I think in these cases fileno() or PyFile_NewStdPrinter() will fail.
I'm trying to consider all possible cases. Standard streams can be: * Left original. * Set to None. * Reopened with different encoding/errors/etc. * Redirected to a file (/dev/null). * Redirected to a socket. * Redirected to inherited file descriptor (pipe) in a subprocess. * Be a high level wrapper around RPC (IDLE subprocess). If the stream was reopened with the same file descriptor and closefd=True, closing it invalidates just opened "standard printer". I would replace stdout and stderr after PyImport_Cleanup(). But PyImport_Cleanup() cleans up the sys module! Thus we should do this inside PyImport_Cleanup(). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26642> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com