Sublime Forum

Python3 exit() results in traceback

#1

Hi, I have Python3.9 and Sublime 3.2.2. When I am building any python 3 script with exit() defined in it, Sublime thow error in the build window.
How can I disable this unnecessary trace back error. Thanks for help. Nothing wrong with script, works file if I run on shell.

import sys
print(sys.version)
exit()

3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10)
[Clang 6.0 (clang-600.0.57)]
Traceback (most recent call last):
File “/test.py”, line 5, in
exit()
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_sitebuiltins.py”, line 26, in call
raise SystemExit(code)
SystemExit: None

0 Likes

#2

What happens when you run it on the command line?

0 Likes

#3

Works fine on command line. Also I been using exit for sometime on Sublime, not sure which version. This is fresh install on Macos BigSur. Updated to latest Sublime today, still same issue.

0 Likes

#4

Here it works fine: ST4, MacOS Big Sur

3.9.5 (default, May 25 2021, 23:36:47)
[Clang 12.0.5 (clang-1205.0.22.9)]
[Finished in 198ms]

Maybe it’s an issue of Python 3.9.2?

Regarding askPython is sys.exit() the recommended way to exit a Python program. Although it’s not really described why exit() is a not ideal solution.

0 Likes

#5

RESOLVED
Think it is to do with the build system. I have configured python3 again with following and it works fine for 3.8 and 3.9 builds.
Source: https://medium.com/@hariyanto.tan95/set-up-sublime-text-3-to-use-python-3-c845b742c720
{
“cmd”: ["/usr/local/bin/python3", “-u”, “$file”],
“file_regex”: “^[ ]File “(…?)”, line ([0-9]*)”,
“selector”: “source.python”
}

0 Likes

#6

Is /usr/bin after /usr/local/bin in your $PATH? It should be the other way around.

0 Likes