Re: [IronPython] SystemExitException ?

2008-11-21 Thread Orestis Markou

Thanks! So we'll remove SystemExitException handling.

Tomas Matousek wrote:

It's handled for you in ExecuteProgram and the exit code is returned. It's this 
handling that makes the difference between Execute and ExecuteProgram. 
ExecuteProgram is designed to process any program exit mechanism that the 
language has so that the host doesn't need to care and could be language 
independent.

Tomas

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Orestis Markou
Sent: Friday, November 21, 2008 5:24 AM
To: Discussion of IronPython
Subject: [IronPython] SystemExitException ?

Hello,

In Resolver, we have our own RSIronPython.exe that sets up the
environment (PATH and other things) and executes a program. It's not
interactive - just a wrapper aroung ExecuteProgram, really.

We used to do this:

try
{
 ScriptSource source =
engine.CreateScriptSourceFromFile(Path.Combine(currentDir,
(string)args[0]));
 source.ExecuteProgram();
}
catch (SystemExitException e)
{
 object o;
 return e.GetExitCode(out o);
}
catch (Exception e)
{
 ExceptionOperations eo = engine.GetService();
 Console.Write(eo.FormatException(e));
 return 1;
}
return 0;

But then we realised that we always returned 0, because
SystemExitException was never raised, even if a PythonScript did an
exlicit sys.exit or raised SystemExit. So we now return the result of
source.ExecuteProgram().

I'm just wondering if we should care about SystemExitException (a quick
grep of the source is indicating that it's only used in
PythonCommandLine), or if it's handled for us at a lower level.

Thanks,
Orestis
--
Orestis Markou
Software Engineer,
Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


--
Orestis Markou
Software Engineer,
Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] SystemExitException ?

2008-11-21 Thread Tomas Matousek
It's handled for you in ExecuteProgram and the exit code is returned. It's this 
handling that makes the difference between Execute and ExecuteProgram. 
ExecuteProgram is designed to process any program exit mechanism that the 
language has so that the host doesn't need to care and could be language 
independent.

Tomas

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Orestis Markou
Sent: Friday, November 21, 2008 5:24 AM
To: Discussion of IronPython
Subject: [IronPython] SystemExitException ?

Hello,

In Resolver, we have our own RSIronPython.exe that sets up the
environment (PATH and other things) and executes a program. It's not
interactive - just a wrapper aroung ExecuteProgram, really.

We used to do this:

try
{
 ScriptSource source =
engine.CreateScriptSourceFromFile(Path.Combine(currentDir,
(string)args[0]));
 source.ExecuteProgram();
}
catch (SystemExitException e)
{
 object o;
 return e.GetExitCode(out o);
}
catch (Exception e)
{
 ExceptionOperations eo = engine.GetService();
 Console.Write(eo.FormatException(e));
 return 1;
}
return 0;

But then we realised that we always returned 0, because
SystemExitException was never raised, even if a PythonScript did an
exlicit sys.exit or raised SystemExit. So we now return the result of
source.ExecuteProgram().

I'm just wondering if we should care about SystemExitException (a quick
grep of the source is indicating that it's only used in
PythonCommandLine), or if it's handled for us at a lower level.

Thanks,
Orestis
--
Orestis Markou
Software Engineer,
Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] SystemExitException ?

2008-11-21 Thread Orestis Markou

Hello,

In Resolver, we have our own RSIronPython.exe that sets up the 
environment (PATH and other things) and executes a program. It's not 
interactive - just a wrapper aroung ExecuteProgram, really.


We used to do this:

try
{
ScriptSource source = 
engine.CreateScriptSourceFromFile(Path.Combine(currentDir, 
(string)args[0]));

source.ExecuteProgram();
}
catch (SystemExitException e)
{
object o;
return e.GetExitCode(out o);
}
catch (Exception e)
{
ExceptionOperations eo = engine.GetService();
Console.Write(eo.FormatException(e));
return 1;
}
return 0;

But then we realised that we always returned 0, because 
SystemExitException was never raised, even if a PythonScript did an 
exlicit sys.exit or raised SystemExit. So we now return the result of 
source.ExecuteProgram().


I'm just wondering if we should care about SystemExitException (a quick 
grep of the source is indicating that it's only used in 
PythonCommandLine), or if it's handled for us at a lower level.


Thanks,
Orestis
--
Orestis Markou
Software Engineer,
Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com