Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 15364:09952d6ed372 legacy-trunk
Fix for SF bug #117241
When a method is called with no regular arguments and * args, defer
the first arg is subclass check until after the * args have been
expanded.
N.B. The CALL_FUNCTION implementation is getting really hairy; should
review it to see if it can be simplified.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Mon, 30 Oct 2000 17:15:20 +0000 |
| parents | 8aa947e1eee8 |
| children | 2481b5fe86d6 |
line wrap: on
line diff
--- a/Python/ceval.c Mon Oct 30 06:24:56 2000 +0000 +++ b/Python/ceval.c Mon Oct 30 17:15:20 2000 +0000 @@ -1822,7 +1822,7 @@ na++; n++; } - else { + else if (!((flags & 1) && na == 0)) { /* Unbound methods must be called with an instance of the class (or a derived class) as first argument */ @@ -1895,6 +1895,20 @@ if (nstar < 0) { goto extcall_fail; } + if (class && self == NULL && na == 0) { + /* * arg is first argument of method, + so check it is isinstance of class */ + self = PyTuple_GET_ITEM(stararg, 0); + if (!(PyInstance_Check(self) && + PyClass_IsSubclass((PyObject *) + (((PyInstanceObject *)self)->in_class), + class))) { + PyErr_SetString(PyExc_TypeError, + "unbound method must be called with instance as first argument"); + x = NULL; + break; + } + } } if (nk > 0) { if (kwdict == NULL) {
