klen/python-mode — pull request #262 by lawrenceakka (2013-08-17 21:57:56+00:00)
Title: Allow Pyrun to deal with sys.exit termination

If a python script terminates with ``` sys.exit() ```, as many do, Pyrun presently reports a Run-time Error. This patch does the right thing: if the script terminates with ``` sys.exit(0) ```, this is treated as successful execution, and Pyrun returns normally. If the script terminates with ``` sys.exit( *some_other_value* ) ```, Pyrun reports an unsuccessful execution, and gives the exit code. This is what, eg, iPython also does. Any other runtime exception will be reported as at present.

Some small test cases:
1)
```python
import sys
# terminate normally. Pyrun should not report any errors
sys.exit(0)
```

2)
```python
import sys
# terminate abnormally. Pyrun should not report abnormal termination, with code 1
sys.exit(1)
```

3)
```python
import sys
# Raise error. Pyrun should provide a traceback
1/0
```