[IronPython] users Digest, Vol 25, Issue 37

Martin Maly Martin.Maly at microsoft.com
Mon Aug 21 21:34:37 CEST 2006


I think that generally people are signed up for the non-digest membership so they get each question/response in separate email, making it easy to respond...

You can change your mailing list membership options to disable digest and receive separate messages ...

M.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Collett
Sent: Monday, August 21, 2006 11:53 AM
To: users at lists.ironpython.com
Subject: Re: [IronPython] users Digest, Vol 25, Issue 37

How does one respond to specific questions and answers in this users lists
scheme in this group.
I just tried respond from Lotus Notes and I will not be sure what happens
till I see the next list emailed.
Thanks
Jeff



             users-request at lis
             ts.ironpython.com
             Sent by:                                                   To
             users-bounces at lis         users at lists.ironpython.com
             ts.ironpython.com                                          cc

                                                                   Subject
             08/21/2006 01:31          users Digest, Vol 25, Issue 37
             PM


             Please respond to
             users at lists.ironp
                 ython.com






Send users mailing list submissions to
             users at lists.ironpython.com

To subscribe or unsubscribe via the World Wide Web, visit
             http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
or, via email, send a message with subject or body 'help' to
             users-request at lists.ironpython.com

You can reach the person managing the list at
             users-owner at lists.ironpython.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of users digest..."


Today's Topics:

   1. engine.ImportSite(); broken in RC2 (Stanislas Pinte)
   2. Re: Code broken in RC2 (Stanislas Pinte)
   3. Re: Getting a line number of error (RC2) (Matt Beckius)
   4. Re: console startup time: 7s (Dino Viehland)
   5. Re: Iron Python Question (Dino Viehland)
   6. Re: engine.ImportSite(); broken in RC2 (Dino Viehland)


----------------------------------------------------------------------

Message: 1
Date: Mon, 21 Aug 2006 18:17:14 +0200
From: Stanislas Pinte <stan at ertmssolutions.com>
Subject: [IronPython] engine.ImportSite(); broken in RC2
To: Discussion of IronPython <users at lists.ironpython.com>
Message-ID: <44E9DC8A.4060401 at ertmssolutions.com>
Content-Type: text/plain; charset=ISO-8859-1

hello,

could you please tell me what happened to engine.ImportSite();, and what
should I change in my code to get same behaviour?

thanks,

Stan.

--
-----------------------------------------------------------------
   Stanislas Pinte             e-mail: stan at ertmssolutions.com
   ERTMS Solutions               http://www.ertmssolutions.com
   Rue de l'Autonomie, 1             Tel:    + 322 - 522.06.63
   1070        Bruxelles              Fax:   + 322 - 522.09.30
-----------------------------------------------------------------
   Skype (http://www.skype.com) id:                  stanpinte
-----------------------------------------------------------------



------------------------------

Message: 2
Date: Mon, 21 Aug 2006 18:21:14 +0200
From: Stanislas Pinte <stan at ertmssolutions.com>
Subject: Re: [IronPython] Code broken in RC2
To: Discussion of IronPython <users at lists.ironpython.com>
Message-ID: <44E9DD7A.80603 at ertmssolutions.com>
Content-Type: text/plain; charset=ISO-8859-1

by looking at IronPythonConsole sources, it seems it might be like:

private static void DefaultExceptionHandler(object sender,
UnhandledExceptionEventArgs args) {
            MyConsole.WriteLine("Unhandled exception: ", Style.Error);

MyConsole.Write(engine.FormatException((Exception)args.ExceptionObject),
Style.Error);
        }

Can anyone from the team confirm this?

Thanks a lot,

Stan.

Stanislas Pinte a ?crit :
> Hello,
>
> I was using the Console class to get a more or less clean dump of
> exceptions in my embedded scripting engine:
>
> DummyConsole dummy = new DummyConsole();
> engine.MyConsole = dummy;
> engine.DumpException(nested);
>
> This code is now broken in IronPython RC2...any suggestions on how to
> fix this?
>
> Thanks a lot,
>
> Stan.
>
> internal class DummyConsole : IConsole
>   {
>     private StringBuilder stringBuilder = new StringBuilder();
>
>     public string ReadLine(int autoIndentSize)
>     {
>       throw new NotImplementedException();
>     }
>
>     public void Write(string text, Style style)
>     {
>       //Console.Out.Write(text, style);
>       stringBuilder.Append(text);
>     }
>
>     public void WriteLine(string text, Style style)
>     {
>       //Console.Out.WriteLine(text, style);
>       stringBuilder.Append(text);
>       stringBuilder.AppendLine();
>     }
>
>     internal string FlushBuffer()
>     {
>       string value = stringBuilder.ToString();
>       stringBuilder = new StringBuilder();
>       return value;
>     }
>   }
>


--
-----------------------------------------------------------------
   Stanislas Pinte             e-mail: stan at ertmssolutions.com
   ERTMS Solutions               http://www.ertmssolutions.com
   Rue de l'Autonomie, 1             Tel:    + 322 - 522.06.63
   1070        Bruxelles              Fax:   + 322 - 522.09.30
-----------------------------------------------------------------
   Skype (http://www.skype.com) id:                  stanpinte
-----------------------------------------------------------------



------------------------------

Message: 3
Date: Mon, 21 Aug 2006 13:44:26 -0400
From: "Matt Beckius" <mbeckius at gmail.com>
Subject: Re: [IronPython] Getting a line number of error (RC2)
To: "Discussion of IronPython" <users at lists.ironpython.com>
Message-ID:
             <ad1f63200608211044g4dc24bc5nfb2cb8db5729f516 at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

No 32bit.  I tried manually setting the TraceBackSupport, but still got the
same result:

IronPython 1.0.60816 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import IronPython
>>>
>>> IronPython.Compiler.Options.TraceBackSupport = True
>>> def Test():
...     print "test"
...     int("test")
...
>>> Test()
test
Traceback (most recent call last):
  File , line 0, in <stdin>##12
  File , line 0, in Test
ValueError: invalid integer number literal
>>>


On 8/21/06, Dino Viehland <dinov at exchange.microsoft.com> wrote:
>
>   Are you running on a 64-bit machine w/ a 64-bit runtime?  By default we
> disable trackback support on 64-bit machines (we've hit a unique bug w/
> exception handling there), but it is enabled on 32-bit machines and
should
> work there.
>
>
>
> If I do:
>
>
>
> import sys
>
> def test2():
>
>     try: test()
>
>     except ValueError, ex:
>
>         global e
>
>         import sys
>
>         e = sys.exc_info()
>
>
>
> test2()
>
> e
>
>
>
> >>> e[2].tb_lineno
>
> 2
>
> >>> e[2].tb_frame.f_code.co_filename
>
> '<stdin>'
>
>
>
> You can enable on 64-bit:
>
>
>
> import IronPython
>
> IronPython.Compiler.Options.TraceBackSupport = True
>
>
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Matt Beckius
> *Sent:* Monday, August 21, 2006 7:18 AM
> *To:* users at lists.ironpython.com
> *Subject:* [IronPython] Getting a line number of error (RC2)
>
>
>
> Trying to get the line number of an error.  CPython produces:
>
>
>
> Python 2.4.2 (#67, Sep 28 2005, 12:41:11)
> Type "help", "copyright", "credits" or "li
> >>> def test():
> ...     print "hi"
> ...     int("hi")
> ...
> >>> test()
> hi
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "<stdin>", line 3, in test
> ValueError: invalid literal for int(): hi
>
>
>
>
>
> But IP RC2 produces:
>
>
>
> IronPython 1.0.60816 on .NET 2.0.50727.42
> Copyright (c) Microsoft Corporation. All rights reserved.
> >>> def test():
> ...     print "hi"
> ...     int("hi")
> ...
> >>> test()
> hi
> Traceback (most recent call last):
>   File , line 0, in <stdin>##5
>   File , line 0, in test
> ValueError: invalid integer number literal
>
>
>
> How do I get the line number of this runtime error?
>
>
>
> MattB
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
/pipermail/users-ironpython.com/attachments/20060821/0d2e29d7/attachment.htm


------------------------------

Message: 4
Date: Mon, 21 Aug 2006 11:30:52 -0700
From: Dino Viehland <dinov at exchange.microsoft.com>
Subject: Re: [IronPython] console startup time: 7s
To: Discussion of IronPython <users at lists.ironpython.com>
Message-ID:

<7AD436E4270DD54A94238001769C2227378F71476B at DF-GRTDANE-MSG.exchange.corp.microsoft.com>


Content-Type: text/plain; charset="us-ascii"

Is this cold startup time, or warm startup time?  On Windows I get:

F:\Product\IronPython\IronPython\Public>type foo.py
print 'hello'

F:\Product\IronPython\IronPython\Public>"C:\Program Files
(x86)\util\TimeIt.exe" "ipy.exe foo.py"
Running ipy.exe foo.py
elapsed time = 1282 milliseconds

this is a warm startup, cold startup is slower than that.  Still plenty of
room for improvement, but it's at least not 7 seconds :).


-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Stanislas Pinte
Sent: Saturday, August 19, 2006 7:20 AM
To: Discussion of IronPython
Subject: [IronPython] console startup time: 7s

I know it is a detail, but 7 seconds is still large...

Any idea why?

[ironpython]> cat hello.py
print 'hello'
[ironpython]> time ipy.exe hello.py
hello

real    0m7.280s
user    0m0.020s
sys     0m0.040s
[ironpython]>



--
-----------------------------------------------------------------
   Stanislas Pinte             e-mail: stan at ertmssolutions.com
   ERTMS Solutions               http://www.ertmssolutions.com
   Rue de l'Autonomie, 1             Tel:    + 322 - 522.06.63
   1070        Bruxelles              Fax:   + 322 - 522.09.30
-----------------------------------------------------------------
   Skype (http://www.skype.com) id:                  stanpinte
-----------------------------------------------------------------
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


------------------------------

Message: 5
Date: Mon, 21 Aug 2006 11:31:01 -0700
From: Dino Viehland <dinov at exchange.microsoft.com>
Subject: Re: [IronPython] Iron Python Question
To: Discussion of IronPython <users at lists.ironpython.com>
Message-ID:

<7AD436E4270DD54A94238001769C2227378F714770 at DF-GRTDANE-MSG.exchange.corp.microsoft.com>


Content-Type: text/plain; charset="us-ascii"

You should be able to do engine.Execute('print myVar2') and it should print
out the value you stored into Globals.

You can also create other modules that have different sets of globals and
pass the EngineModule to the overload of Execute that takes one of those.

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Collett
Sent: Monday, August 21, 2006 5:35 AM
To: users at lists.ironpython.com
Subject: [IronPython] Iron Python Question


Hi All,
I just started using Iron Python and I am bit unsure on the best way to
pass data from the app that runs the script and the script itself.
So far I know that we should do something like this from say a C#
application,

PythonEngine.Globals["myVar"] = myVar;

So from the looks of this it is a global array for storing data.
Can I do this then,
PythonEngine.Globals["myVar"] = myVar;
PythonEngine.Globals["myVar2"] = myVar2; PythonEngine.Globals["myVar3"] =
myVar3;

Then how would I access this data from the script.
Example of which I do not think I can do from the script, myVar =
PythonEngine.Globals["myVar"]
myVar2 = PythonEngine.Globals["myVar2"]

Thanks for any advice.
Jeff


Although this e-mail and any attachments are believed to be free of any
virus or other defect which might affect any computer system, it is the
responsibility of the recipient to check that it is virus-free and the
sender accepts no responsibility or liability for any loss, injury, damage,
cost or expense arising in any way from receipt or use thereof by the
recipient.

The information contained in this electronic mail message is confidential
information and intended only for the use of the individual or entity named
above, and may be privileged.  If the reader of this message is not the
intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.  If
you have received this transmission in error, please  contact the sender
immediately, delete this material from your computer and destroy all
related paper media.  Please note that the documents transmitted are not
intended to be binding until a hard copy has been manually signed by all
parties.
Thank you.
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


------------------------------

Message: 6
Date: Mon, 21 Aug 2006 11:31:11 -0700
From: Dino Viehland <dinov at exchange.microsoft.com>
Subject: Re: [IronPython] engine.ImportSite(); broken in RC2
To: Discussion of IronPython <users at lists.ironpython.com>
Message-ID:

<7AD436E4270DD54A94238001769C2227378F714774 at DF-GRTDANE-MSG.exchange.corp.microsoft.com>


Content-Type: text/plain; charset="us-ascii"

This has moved to just being engine.Import("site") after you make sure you
have site on your path.  Basically this has moved into the console code:

        private static void ImportSite(PythonEngine engine) {
            if (!ConsoleOptions.ImportSite)
                return;
            string site =
System.Reflection.Assembly.GetExecutingAssembly().Location;
            site = Path.Combine(Path.GetDirectoryName(site), "Lib");
            engine.AddToPath(site);
            try {
                engine.Import("site");
            } catch (Exception e) {
                MyConsole.Write(engine.FormatException(e), Style.Error);
            }
        }

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Stanislas Pinte
Sent: Monday, August 21, 2006 9:17 AM
To: Discussion of IronPython
Subject: [IronPython] engine.ImportSite(); broken in RC2

hello,

could you please tell me what happened to engine.ImportSite();, and what
should I change in my code to get same behaviour?

thanks,

Stan.

--
-----------------------------------------------------------------
   Stanislas Pinte             e-mail: stan at ertmssolutions.com
   ERTMS Solutions               http://www.ertmssolutions.com
   Rue de l'Autonomie, 1             Tel:    + 322 - 522.06.63
   1070        Bruxelles              Fax:   + 322 - 522.09.30
-----------------------------------------------------------------
   Skype (http://www.skype.com) id:                  stanpinte
-----------------------------------------------------------------

_______________________________________________
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


End of users Digest, Vol 25, Issue 37
*************************************



Although this e-mail and any attachments are believed to be free of any virus or other defect which might affect any computer system, it is the responsibility of the recipient to check that it is virus-free and the sender accepts no responsibility or liability for any loss, injury, damage, cost or expense arising in any way from receipt or use thereof by the recipient.

The information contained in this electronic mail message is confidential information and intended only for the use of the individual or entity named above, and may be privileged.  If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this transmission in error, please  contact the sender immediately, delete this material from your computer and destroy all related paper media.  Please note that the documents transmitted are not intended to be binding until a hard copy has been manually signed by all parties.
Thank you.
_______________________________________________
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