[IronPython] SystemExitException ?

Tomas Matousek Tomas.Matousek at microsoft.com
Fri Nov 21 17:31:27 CET 2008


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: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] 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<ExceptionOperations>();
     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.
orestis at resolversystems.com
+44 (0) 20 7253 6372

_______________________________________________
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