diff options
author | Guido van Rossum <guido@python.org> | 1998-07-08 14:58:16 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-07-08 14:58:16 (GMT) |
commit | 7859f87fdbcc0679aa6ed9c181ee3826002ac5ca (patch) | |
tree | 21deb8482707e62cf1b6a4d002c97d12a03eb3c3 /Modules/newmodule.c | |
parent | bb71ab68f9c376a5cda676fa35713cea34783fc0 (diff) | |
download | cpython-7859f87fdbcc0679aa6ed9c181ee3826002ac5ca.zip cpython-7859f87fdbcc0679aa6ed9c181ee3826002ac5ca.tar.gz cpython-7859f87fdbcc0679aa6ed9c181ee3826002ac5ca.tar.bz2 |
Marc-Andre Lemburg's patch to support instance methods with other
callable objects than regular Pythonm functions as their im_func.
Diffstat (limited to 'Modules/newmodule.c')
-rw-r--r-- | Modules/newmodule.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Modules/newmodule.c b/Modules/newmodule.c index cfe7883..52328a9 100644 --- a/Modules/newmodule.c +++ b/Modules/newmodule.c @@ -71,11 +71,23 @@ new_instancemethod(unused, args) PyObject* self; PyObject* classObj; - if (!PyArg_ParseTuple(args, "O!O!O!", - &PyFunction_Type, &func, - &PyInstance_Type, &self, + if (!PyArg_ParseTuple(args, "OOO!", + &func, + &self, &PyClass_Type, &classObj)) return NULL; + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, + "first argument must be callable"); + return NULL; + } + 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); } |