Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 22603:2868e9a9e280 | 22604:3f4b2f93e8b5 |
|---|---|
| 144 This should be called from inside an except clause only."; | 144 This should be called from inside an except clause only."; |
| 145 | 145 |
| 146 static PyObject * | 146 static PyObject * |
| 147 sys_exit(PyObject *self, PyObject *args) | 147 sys_exit(PyObject *self, PyObject *args) |
| 148 { | 148 { |
| 149 PyObject *exit_code = 0; | |
| 150 if (!PyArg_ParseTuple(args, "|O:exit", &exit_code)) | |
| 151 return NULL; | |
| 149 /* Raise SystemExit so callers may catch it or clean up. */ | 152 /* Raise SystemExit so callers may catch it or clean up. */ |
| 150 PyErr_SetObject(PyExc_SystemExit, args); | 153 PyErr_SetObject(PyExc_SystemExit, exit_code); |
| 151 return NULL; | 154 return NULL; |
| 152 } | 155 } |
| 153 | 156 |
| 154 static char exit_doc[] = | 157 static char exit_doc[] = |
| 155 "exit([status])\n\ | 158 "exit([status])\n\ |
| 526 static PyMethodDef sys_methods[] = { | 529 static PyMethodDef sys_methods[] = { |
| 527 /* Might as well keep this in alphabetic order */ | 530 /* Might as well keep this in alphabetic order */ |
| 528 {"displayhook", sys_displayhook, METH_O, displayhook_doc}, | 531 {"displayhook", sys_displayhook, METH_O, displayhook_doc}, |
| 529 {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, exc_info_doc}, | 532 {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, exc_info_doc}, |
| 530 {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, | 533 {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, |
| 531 {"exit", sys_exit, METH_OLDARGS, exit_doc}, | 534 {"exit", sys_exit, METH_VARARGS, exit_doc}, |
| 532 #ifdef Py_USING_UNICODE | 535 #ifdef Py_USING_UNICODE |
| 533 {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, | 536 {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, |
| 534 getdefaultencoding_doc}, | 537 getdefaultencoding_doc}, |
| 535 #endif | 538 #endif |
| 536 #ifdef HAVE_DLOPEN | 539 #ifdef HAVE_DLOPEN |
