[IronPython] IronPython 2 Bug - code module and InteractiveInterpreter (stdout swallowed or not appearing)
Michael Foord
fuzzyman at voidspace.org.uk
Wed Sep 19 18:29:40 CEST 2007
Cool - you're a legend. :-)
Of course I'll have to wait for the next release of Silverlight to
really see this (unless I can figure out how to compile the DLR as a
Silverlight project - I failed *last* time I tried).
Thanks
Michael
http://www.manning.com/foord
Dino Viehland wrote:
> This is because Builtin.compile is setting the SourceCodeKind to SourceCodeKind.SingleStatement and we don't turn on printExpressions for SingleStatements.
>
> In IronPython.Compiler.Parser there is a method ParseSingleStatement. You just need to change the last parameter when newing up the PythonAst to true from false and it'll work. It should be a perfectly safe change as this is the only place in the world that uses SourceCodeKind.SingleStatement.
>
> I'll probably check-in the fix today and add a test case so we don't break it in the future - so you'll see this in the next release.
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
> Sent: Wednesday, September 19, 2007 6:23 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] IronPython 2 Bug - code module and InteractiveInterpreter (stdout swallowed or not appearing)
>
> Hello all (again),
>
> A simpler way of reproducing the bug is as follows:
>
> IronPython 1 and CPython
> >>> c = compile('3', 'test', 'single', 0, 1)
> >>> exec c
> 3
> >>>
>
> IronPython 2
> >>> c = compile('3', 'test', 'single', 0, 1)
> >>> exec c
> >>>
>
> I have a 'proof-of-concept' interpreter that runs in the browser, but
> this bug makes it not so fun. :-(
>
> Michael Foord
> http://www.ironpython.info/
>
>
>
>
> Michael Foord wrote:
>
>> Hello all,
>>
>> There is an annoying bug with IronPython 2 which is blocking me from
>> implementing an 'interactive interpreter in the browser'.
>>
>> I'm afraid I can only show how to reproduce the bug rather than
>> diagnose the cause.
>>
>> When executing code with the 'InteractiveInterpreter' class from the
>> standard library code module, the result of the last expression is
>> sent to stdout. This mirrors the behaviour of the normal Python
>> interactive interpreter.
>>
>> In IronPython 1.1 this works fine - and I can trap the output by
>> replacing 'sys.stdout' with my own Python object.
>>
>> In IronPython 2, this output just doesn't appear. :-(
>>
>> If you run 'test_console.py' (with the other attached files in the
>> same directory) with IronPython 1.1 it will print the following line
>> to standard out "Received (out) : 3Received (out) :".
>>
>> If you run it with IronPython 2 (I've tried it with both Silverlight
>> and 2.0a4) it outputs nothing.
>>
>> This is a darn shame because having an interactive interpreter in the
>> browser is way cool...
>>
>> Michael Foord
>> http://www.manning.com/foord
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> 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