summaryrefslogtreecommitdiffstats
path: root/Modules/newmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-11-13 20:29:20 (GMT)
committerGuido van Rossum <guido@python.org>2000-11-13 20:29:20 (GMT)
commit1bff883ac07b901c6199e0f79c3f93330ab24eae (patch)
tree271a8271a711bf189d7e8dffe880cb01ea4d3751 /Modules/newmodule.c
parentecaa77798b7004e02e5893b0da9493b25f121509 (diff)
downloadcpython-1bff883ac07b901c6199e0f79c3f93330ab24eae.zip
cpython-1bff883ac07b901c6199e0f79c3f93330ab24eae.tar.gz
cpython-1bff883ac07b901c6199e0f79c3f93330ab24eae.tar.bz2
Allow new.function() called with explicit 3rd arg of None, as
documented, and as is reasonable (since it is optional, but there's another argument following it that may require you to specify a value). This solves SF bug 121887.
Diffstat (limited to 'Modules/newmodule.c')
-rw-r--r--Modules/newmodule.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/newmodule.c b/Modules/newmodule.c
index 456e440..21b82ef 100644
--- a/Modules/newmodule.c
+++ b/Modules/newmodule.c
@@ -70,12 +70,17 @@ new_function(PyObject* unused, PyObject* args)
PyObject* defaults = Py_None;
PyFunctionObject* newfunc;
- if (!PyArg_ParseTuple(args, "O!O!|SO!:function",
+ if (!PyArg_ParseTuple(args, "O!O!|OO!:function",
&PyCode_Type, &code,
&PyDict_Type, &globals,
&name,
&PyTuple_Type, &defaults))
return NULL;
+ if (name != Py_None && !PyString_Check(name)) {
+ PyErr_SetString(PyExc_TypeError,
+ "arg 3 (name) must be None or string");
+ return NULL;
+ }
newfunc = (PyFunctionObject *)PyFunction_New(code, globals);
if (newfunc == NULL)