Issue1405

classification
Title: Executing __run__.py from .jar throws exception(SystemExit: 0) in main when sys.exit(0) is called
Type: behaviour Severity: major
Components: Core Versions: 2.5.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, leosoto, whistler11783
Priority: Keywords:

Created on 2009-07-17.20:37:16 by whistler11783, last changed 2009-08-07.14:48:30 by fwierzbicki.

Messages
msg4916 (view) Author: Robert Scrimo (whistler11783) Date: 2009-07-17.20:37:15
__run__.py script at root level of myscript.jar(copy of jython.jar):

-- __run__.py --
import sys
sys.exit(0)
-- __run__.py --

# java org.python.util.jython -jar myscript.jar
Upon executing the sys.exit(0) call(last line in script) in my main I
recieve the following exception:
Exception in thread "main" Traceback (most recent call last):
File "__run__", line 2, in
SystemExit: 0  
# echo $?
1

The script exit code is set to a 1 because an SystemExit exception is
thrown which is expected at exit if it is unhandled but I am calling
sys.exit(0) to set the exit code to 0 and in the main(top level) it
should not be throwing or at least propagating the exception upon
termination.

This behaviour does not occur when executing this same script outside of
the .jar(not as __run__.py)

# /jython2.5.0/jython myscript.py
# echo $?
0

This is the correct behavior
msg5002 (view) Author: Leonardo Soto (leosoto) Date: 2009-08-06.20:18:25
Fixed on r6634.

Frank: Any idea on how to add a test for this bug?
msg5006 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-08-07.14:48:30
Leo: the best support for this sort of unix-specific shell test that I
know of would be to add to the script tests/shell/test-jython.sh.  Looks
like Nicholas Riley wrote it.  It is exercised by the ant task
"launchertest"
History
Date User Action Args
2009-08-07 14:48:30fwierzbickisetmessages: + msg5006
2009-08-06 20:18:26leosotosetstatus: open -> closed
resolution: fixed
messages: + msg5002
nosy: + leosoto
2009-07-19 15:13:23fwierzbickisetnosy: + fwierzbicki
2009-07-17 20:37:16whistler11783create