[IronPython] Expression printing in interactive mode

Dino Viehland dinov at microsoft.com
Wed Apr 29 20:13:12 CEST 2009

There was some internal work going on w/ running a remote console
and it looks like this change was related to that.  In 
Microsoft.Scripting.Hosting.Shell there's a comment added to its 
RunOneInteraction w/ the same change:

        /// We check if the code read is an interactive command or statements is by checking for NewLine
        /// If the code contains NewLine, it's a set of statements (most probably from SendToConsole)
        /// If the code does not contain a NewLine, it's an interactive command typed by the user at the prompt

Looking at the code thought I'm guessing this is totally broken on 
Unix because in ReadStatement we append a newline, with a 
wonderful comment there:

                // Note that this does not use Environment.NewLine because some languages (eg. Python) only
                // recognize \n as a line terminator.

So this just happens to do the right thing on Windows due to the
mismatches between the new lines being used.

I guess we should actually be checking for more than one "\n".

> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of Seo Sanghyeon
> Sent: Wednesday, April 29, 2009 10:48 AM
> To: Discussion of IronPython
> Subject: [IronPython] Expression printing in interactive mode
> In changeset 42603, a change was made to
> IronPython.Hosting.PythonCommandLine.RunOneInteraction,
> - SourceUnit su = Language.CreateSnippet(s, "<stdin>",
> SourceCodeKind.InteractiveCode);
> + SourceUnit su = Language.CreateSnippet(s, "<stdin>",
> (s.Contains(Environment.NewLine))? SourceCodeKind.Statements :
> SourceCodeKind.InteractiveCode);
> Why is this? It seems to me that s always contains newline, so its net
> effect is making all interactive code non-interactive. In Python, this
> means no expression is printed in interactive mode.
> --
> Seo Sanghyeon
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

More information about the Ironpython-users mailing list