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

Dino Viehland dinov at exchange.microsoft.com
Thu Apr 27 17:38:25 CEST 2006

Yep, you're correct - SystemState is currently a singleton for the entire process.  We'll actually have this fixed in beta 7 where the system state is stored in a hidden spot in the module and we'll flow it as one module imports another.  That'll result in a set of modules being independent and 'belonging' to a single system state and allows multiple engines to be hosted simultaneously.

The engine does have a SetStderr / SetStdout / SetStdin API which should be used for this purpose.  And the nice thing is as we rev to the multi-System state module this API will remain unchanged so you won't be broken in the future.

Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jean-Michel.Perraud at csiro.au
Sent: Thursday, April 27, 2006 4:32 AM
To: users at lists.ironpython.com
Subject: [IronPython] Generated IL is always using the standard input, output and error streams.


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


users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list