]> granicus.if.org Git - python/commitdiff
There's no need for typechecks on the second and third argument of
authorGuido van Rossum <guido@python.org>
Tue, 15 Jan 2002 19:21:05 +0000 (19:21 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 15 Jan 2002 19:21:05 +0000 (19:21 +0000)
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.

Doc/lib/libnew.tex
Modules/newmodule.c

index 9547b588a635e458b21d1076a47f6efa3952858a..67bfb2ed797200a203c26627976e91dc704d09ab 100644 (file)
@@ -25,8 +25,7 @@ the object will be in a consistent state.
 \begin{funcdesc}{instancemethod}{function, instance, class}
 This function will return a method object, bound to \var{instance}, or
 unbound if \var{instance} is \code{None}.  \var{function} must be
-callable, and \var{instance} must be an instance object or
-\code{None}.
+callable.
 \end{funcdesc}
 
 \begin{funcdesc}{function}{code, globals\optional{, name\optional{, argdefs}}}
index 252637ab524eacc95d603aff61034163327a4650..0a48926da65ef1809b3323ebfe5fcdaf77ca5cf2 100644 (file)
@@ -40,10 +40,8 @@ new_instancemethod(PyObject* unused, PyObject* args)
        PyObject* self;
        PyObject* classObj;
 
-       if (!PyArg_ParseTuple(args, "OOO!:instancemethod",
-                             &func,
-                             &self,
-                             &PyClass_Type, &classObj))
+       if (!PyArg_ParseTuple(args, "OOO:instancemethod",
+                             &func, &self, &classObj))
                return NULL;
        if (!PyCallable_Check(func)) {
                PyErr_SetString(PyExc_TypeError,
@@ -52,11 +50,6 @@ new_instancemethod(PyObject* unused, PyObject* args)
        }
        if (self == Py_None)
                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);
 }