There's no need for typechecks on the second and third argument of

new.instancemethod() -- the instancemethod object is now a perfectly
general container.

This fixes SF bug ##503091 (Pedro Rodriquez): new.instancemethod fails
for new classes

This is a 2.2.1 candidate.
This commit is contained in:
Guido van Rossum 2002-01-15 19:21:05 +00:00
parent 5e99731ab9
commit 4f3a62d9bc
2 changed files with 3 additions and 11 deletions

View File

@ -25,8 +25,7 @@ the object will be in a consistent state.
\begin{funcdesc}{instancemethod}{function, instance, class} \begin{funcdesc}{instancemethod}{function, instance, class}
This function will return a method object, bound to \var{instance}, or This function will return a method object, bound to \var{instance}, or
unbound if \var{instance} is \code{None}. \var{function} must be unbound if \var{instance} is \code{None}. \var{function} must be
callable, and \var{instance} must be an instance object or callable.
\code{None}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{function}{code, globals\optional{, name\optional{, argdefs}}} \begin{funcdesc}{function}{code, globals\optional{, name\optional{, argdefs}}}

View File

@ -40,10 +40,8 @@ new_instancemethod(PyObject* unused, PyObject* args)
PyObject* self; PyObject* self;
PyObject* classObj; PyObject* classObj;
if (!PyArg_ParseTuple(args, "OOO!:instancemethod", if (!PyArg_ParseTuple(args, "OOO:instancemethod",
&func, &func, &self, &classObj))
&self,
&PyClass_Type, &classObj))
return NULL; return NULL;
if (!PyCallable_Check(func)) { if (!PyCallable_Check(func)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
@ -52,11 +50,6 @@ new_instancemethod(PyObject* unused, PyObject* args)
} }
if (self == Py_None) if (self == Py_None)
self = NULL; self = NULL;
else if (!PyInstance_Check(self)) {
PyErr_SetString(PyExc_TypeError,
"second argument must be instance or None");
return NULL;
}
return PyMethod_New(func, self, classObj); return PyMethod_New(func, self, classObj);
} }