According to the documentation on sys.exit
and SystemExit
, it seems that
def sys.exit(return_value=None): # or return_value=0raise SystemExit(return_value)
is that correct or does sys.exit
do something else before?
According to the documentation on sys.exit
and SystemExit
, it seems that
def sys.exit(return_value=None): # or return_value=0raise SystemExit(return_value)
is that correct or does sys.exit
do something else before?
According to Python/sysmodule.c
, raising SystemExit
is all it does.
static PyObject *
sys_exit(PyObject *self, PyObject *args)
{PyObject *exit_code = 0;if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code))return NULL;/* Raise SystemExit so callers may catch it or clean up. */PyErr_SetObject(PyExc_SystemExit, exit_code);return NULL;
}