[Python-checkins] CVS: python/dist/src/Modules newmodule.c,2.28,2.29

Guido van Rossum python-dev@python.org
2000年11月13日 12:29:23 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv9978
Modified Files:
	newmodule.c 
Log Message:
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.
Index: newmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/newmodule.c,v
retrieving revision 2.28
retrieving revision 2.29
diff -C2 -r2.28 -r2.29
*** newmodule.c	2000年10月10日 22:07:18	2.28
--- newmodule.c	2000年11月13日 20:29:20	2.29
***************
*** 71,75 ****
 	PyFunctionObject* newfunc;
 
! 	if (!PyArg_ParseTuple(args, "O!O!|SO!:function",
 			 &PyCode_Type, &code,
 			 &PyDict_Type, &globals,
--- 71,75 ----
 	PyFunctionObject* newfunc;
 
! 	if (!PyArg_ParseTuple(args, "O!O!|OO!:function",
 			 &PyCode_Type, &code,
 			 &PyDict_Type, &globals,
***************
*** 77,80 ****
--- 77,85 ----
 			 &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);

AltStyle によって変換されたページ (->オリジナル) /