Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 22604:3f4b2f93e8b5 legacy-trunk
Change sys_exit to use METH_VARARGS.
sys.exit() now requires 0-1 arguments. Previously 2+ arguments were allowed.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Wed, 27 Mar 2002 13:03:09 +0000 |
| parents | ef314b37e260 |
| children | 43ddcdcd3c71 |
line wrap: on
line diff
--- a/Python/sysmodule.c Wed Mar 27 12:15:57 2002 +0000 +++ b/Python/sysmodule.c Wed Mar 27 13:03:09 2002 +0000 @@ -146,8 +146,11 @@ static PyObject * sys_exit(PyObject *self, PyObject *args) { + PyObject *exit_code = 0; + if (!PyArg_ParseTuple(args, "|O:exit", &exit_code)) + return NULL; /* Raise SystemExit so callers may catch it or clean up. */ - PyErr_SetObject(PyExc_SystemExit, args); + PyErr_SetObject(PyExc_SystemExit, exit_code); return NULL; } @@ -528,7 +531,7 @@ {"displayhook", sys_displayhook, METH_O, displayhook_doc}, {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, exc_info_doc}, {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, - {"exit", sys_exit, METH_OLDARGS, exit_doc}, + {"exit", sys_exit, METH_VARARGS, exit_doc}, #ifdef Py_USING_UNICODE {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, getdefaultencoding_doc},
