{"action":"created","issue":{"url":"https://api.github.com/repos/ipython/ipython/issues/9141","repository_url":"https://api.github.com/repos/ipython/ipython","labels_url":"https://api.github.com/repos/ipython/ipython/issues/9141/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipython/issues/9141/comments","events_url":"https://api.github.com/repos/ipython/ipython/issues/9141/events","html_url":"https://github.com/ipython/ipython/issues/9141","id":127464688,"number":9141,"title":"Do we remember why utils.io.IOStream exists?","user":{"login":"takluyver","id":327925,"avatar_url":"https://avatars.githubusercontent.com/u/327925?v=3","gravatar_id":"","url":"https://api.github.com/users/takluyver","html_url":"https://github.com/takluyver","followers_url":"https://api.github.com/users/takluyver/followers","following_url":"https://api.github.com/users/takluyver/following{/other_user}","gists_url":"https://api.github.com/users/takluyver/gists{/gist_id}","starred_url":"https://api.github.com/users/takluyver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takluyver/subscriptions","organizations_url":"https://api.github.com/users/takluyver/orgs","repos_url":"https://api.github.com/users/takluyver/repos","events_url":"https://api.github.com/users/takluyver/events{/privacy}","received_events_url":"https://api.github.com/users/takluyver/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ipython/ipython/milestones/25","html_url":"https://github.com/ipython/ipython/milestones/5.0","labels_url":"https://api.github.com/repos/ipython/ipython/milestones/25/labels","id":1020999,"number":25,"title":"5.0","description":"","creator":{"login":"Carreau","id":335567,"avatar_url":"https://avatars.githubusercontent.com/u/335567?v=3","gravatar_id":"","url":"https://api.github.com/users/Carreau","html_url":"https://github.com/Carreau","followers_url":"https://api.github.com/users/Carreau/followers","following_url":"https://api.github.com/users/Carreau/following{/other_user}","gists_url":"https://api.github.com/users/Carreau/gists{/gist_id}","starred_url":"https://api.github.com/users/Carreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carreau/subscriptions","organizations_url":"https://api.github.com/users/Carreau/orgs","repos_url":"https://api.github.com/users/Carreau/repos","events_url":"https://api.github.com/users/Carreau/events{/privacy}","received_events_url":"https://api.github.com/users/Carreau/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":120,"state":"open","created_at":"2015-03-13T21:27:20Z","updated_at":"2016-05-20T21:23:41Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2016-01-19T15:02:38Z","updated_at":"2016-05-23T16:54:09Z","closed_at":null,"body":"`IPython.utils.io` has stdin, stdout and stderr attributes which wrap the corresponding stream objects from `sys` in an `IOStream` instance. Then certain odd places around the codebase, such as oinspect, do `print(..., file=io.stdout)`, while other places don't.\r\n\r\nI assume that this was originally supposed to provide an indirection layer so stdout/stderr could easily be redirected. However:\r\n\r\n- Things that redirect stdout/stderr typically replace them directly in `sys` - they have to, because not all printing is directed through the `IPython.utils.io` objects. There are backup copies of the original objects as e.g. `sys.__stdout__`, so replacing `sys.stdout` is not destructive.\r\n- When `sys.std*` is replaced, `io.std*` still has a reference to the original `sys.std*` objects, so it doesn't respect the redirection. See issue #8669, and I also just ran into this trying to use colorama in #9118.\r\n\r\nI'm proposing that we deprecate `io.std*`, and move all uses of it in our own code to `sys.std*`. Does anyone know of a reason *not* to do this?\r\n\r\nPing @fperez, because I'm pretty sure this code has been around longer than I've been on the project."},"comment":{"url":"https://api.github.com/repos/ipython/ipython/issues/comments/221030057","html_url":"https://github.com/ipython/ipython/issues/9141#issuecomment-221030057","issue_url":"https://api.github.com/repos/ipython/ipython/issues/9141","id":221030057,"user":{"login":"Carreau","id":335567,"avatar_url":"https://avatars.githubusercontent.com/u/335567?v=3","gravatar_id":"","url":"https://api.github.com/users/Carreau","html_url":"https://github.com/Carreau","followers_url":"https://api.github.com/users/Carreau/followers","following_url":"https://api.github.com/users/Carreau/following{/other_user}","gists_url":"https://api.github.com/users/Carreau/gists{/gist_id}","starred_url":"https://api.github.com/users/Carreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carreau/subscriptions","organizations_url":"https://api.github.com/users/Carreau/orgs","repos_url":"https://api.github.com/users/Carreau/repos","events_url":"https://api.github.com/users/Carreau/events{/privacy}","received_events_url":"https://api.github.com/users/Carreau/received_events","type":"User","site_admin":false},"created_at":"2016-05-23T16:54:09Z","updated_at":"2016-05-23T16:54:09Z","body":"> +1 to not messing around with sys. Neat as the above code may be, I concur with Thomas above. Too dangerous to be worth the trouble.\r\n\r\nYes, I was aware that was a bad idea.\r\n\r\nSidenote, we have that in `globalipapp`:\r\n\r\n```\r\nclass StreamProxy(io.IOStream):\r\n    \"\"\"Proxy for sys.stdout/err.  This will request the stream *at call time*\r\n    allowing for nose's Capture plugin's redirection of sys.stdout/err.\r\n\r\n    Parameters\r\n    ----------\r\n    name : str\r\n        The name of the stream. This will be requested anew at every call\r\n    \"\"\"\r\n```\r\n\r\nSo it seem that iostream does have a useful usage. "}}
{"actor":{"display_login":"Carreau"}}