Commit 0c07583c authored by Neal Norwitz's avatar Neal Norwitz

Change sys_exit to use METH_VARARGS.

sys.exit() now requires 0-1 arguments.  Previously 2+ arguments were allowed.
parent b174da5b
...@@ -26,6 +26,9 @@ Core and builtins ...@@ -26,6 +26,9 @@ Core and builtins
- posix.killpg has been added where available. - posix.killpg has been added where available.
- sys.exit() inadvertantly allowed more than one argument.
An exception will now be raised if more than one argument is used.
Extension modules Extension modules
- A security hole ("double free") was found in zlib-1.1.3, a popular - A security hole ("double free") was found in zlib-1.1.3, a popular
......
...@@ -146,8 +146,11 @@ This should be called from inside an except clause only."; ...@@ -146,8 +146,11 @@ This should be called from inside an except clause only.";
static PyObject * static PyObject *
sys_exit(PyObject *self, PyObject *args) 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. */ /* Raise SystemExit so callers may catch it or clean up. */
PyErr_SetObject(PyExc_SystemExit, args); PyErr_SetObject(PyExc_SystemExit, exit_code);
return NULL; return NULL;
} }
...@@ -528,7 +531,7 @@ static PyMethodDef sys_methods[] = { ...@@ -528,7 +531,7 @@ static PyMethodDef sys_methods[] = {
{"displayhook", sys_displayhook, METH_O, displayhook_doc}, {"displayhook", sys_displayhook, METH_O, displayhook_doc},
{"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, exc_info_doc}, {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, exc_info_doc},
{"excepthook", sys_excepthook, METH_VARARGS, excepthook_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 #ifdef Py_USING_UNICODE
{"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS,
getdefaultencoding_doc}, getdefaultencoding_doc},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment