Pythonista-Issues icon indicating copy to clipboard operation
Pythonista-Issues copied to clipboard

Pythonista doesn't catch SystemExit exception

Open pietvo opened this issue 1 year ago • 3 comments

The following python script gives the expected output on Python 3.10 (and other versions) on MacOS, but not in Pythonista 3 (version 3.4).


import sys

print('''
This should print:
Start
Caught SystemExit:  Test
After Exit
''')


try:
    print('Start')
    sys.exit('Test')
    print('This should not be printed')
except SystemExit as e:
    print('Caught SystemExit: ', e)
print('After Exit')

If SystemExit is replaced by BaseException, it works.

pietvo avatar Oct 31 '24 18:10 pietvo