mirror of
https://github.com/python/cpython
synced 2026-09-29 10:35:30 +03:00
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.
This commit is contained in:
parent
ecaa77798b
commit
1bff883ac0
1 changed files with 6 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue