Repository navigation
Table.pprint() header ignores stdout redirection - #2878
Conversation
|
ISTM the real issue here is incompatibility between |
|
In fact that's exactly it. In the context manager |
|
@embray - ok, looked at it correctly prints to file with the redirection, and correctly prints color before and after. Would using |
|
It specifically has to do with using IPython's I'll have to experiment, but I think it should be possible to make our own |
|
Incidentally, this appears to be broken now in IPython 2.0 where I get: so definitely needs to be reworked :( |
for functions like color_print, ProgressBar, etc. is obtained. Usually we just want to use sys.stdout, but on Windows that does not work for color. Previously there were some hacks to instead use IPython's stdio stream on Windows since it actually wraps pyreadline and *does* handle colors. However, by *always* using IPython's stdout, functions that assume we're using sys.stdout do not actually write properly to sys.stdout when sys.stdout is *changed* (e.g. replaced with a log file). This instead uses sys.stdout by default in *most* cases. But when sys.stdout is set to a TTY (the only context where we probably want to keep colors) *then* it switches over to using IPython's stdout. An alternative might be to create a wrapper object that handles this more transparently, but for now this appears to work.
|
Attached a reworking of how the correct Note: There's not much point in trying to cook up a regression test for this since this is only really an issue in IPython anyways. |
|
I guess I am still confused why on windows it is not fine to just write to |
|
No, IPython doesn't redirect |
Table.pprint() header ignores stdout redirection
Table.pprint() header ignores stdout redirection
As found in #2869, if one tries to redirect the output from
Table.pprint(), the data get redirected, but the header does not (see below). My guess is that this is becausecolor_print, which is used for the header, does not write to stdout.