[IronPython] Generated IL is always using the standard input, output and error streams.

Jean-Michel.Perraud at csiro.au Jean-Michel.Perraud at csiro.au
Thu Apr 27 13:31:48 CEST 2006


First, thanks Dino and Szymon for the help <Re: Using an IronPython
console with a Winforms component supporting the interactive I/O>

I came across an issue: the only output displayed were stack traces. 

After a bit of investigation, I think the generated IL does not use the
custom streams of the implementation of IConsole passed to the
PythonEngine. The static property State of IP::Runtime::Ops is
initialised with a SystemState setting its fields e.g. as:

        public object __stdout__ = new PythonFile(
            Options.UnbufferedStdOutAndError ?
Console.OpenStandardOutput(0) : Console.OpenStandardOutput(),

I think that the subsequent calls to the methods in the Ops class from
the generated methods are using this State.

Incidentally, the use of static methods/properties for Ops also
effectively means that a PythonEngine should be used as a singleton if
embedded in an application. I am well aware that trying not to rely on
static method and singleton patterns often raises the code complexity a
*lot* (been there, done that...). What is the current thinking on this


More information about the Ironpython-users mailing list