From: Georg Brandl Date: Sat, 30 Sep 2006 08:43:35 +0000 (+0000) Subject: Patch #1567691: super() and new.instancemethod() now don't accept X-Git-Tag: v2.4.4c1~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adf8a1d0cb146f91ceff8963bd4b95dbe015a89f;p=thirdparty%2FPython%2Fcpython.git Patch #1567691: super() and new.instancemethod() now don't accept keyword arguments any more (previously they accepted them, but didn't use them). (backport from rev. 52058) --- diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 4fb3b5269b54..a31a9f0cdf7e 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -2077,6 +2077,13 @@ def supers(): veris(Sub.test(), Base.aProp) + # Verify that super() doesn't allow keyword args + try: + super(Base, kw=1) + except TypeError: + pass + else: + raise TestFailed, "super shouldn't accept keyword args" def inherits(): if verbose: print "Testing inheritance from basic types..." diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py index 4aab1e268b06..eb7a40792dc4 100644 --- a/Lib/test/test_new.py +++ b/Lib/test/test_new.py @@ -57,6 +57,14 @@ except TypeError: else: raise TestFailed, "dangerous instance method creation allowed" +# Verify that instancemethod() doesn't allow keyword args +try: + new.instancemethod(break_yolks, c, kw=1) +except TypeError: + pass +else: + raise TestFailed, "instancemethod shouldn't accept keyword args" + # It's unclear what the semantics should be for a code object compiled at # module scope, but bound and run in a function. In CPython, `c' is global # (by accident?) while in Jython, `c' is local. The intent of the test diff --git a/Misc/NEWS b/Misc/NEWS index 73515e63115e..284825e352f1 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,10 @@ What's New in Python 2.4.4c1? Core and builtins ----------------- +- Patch #1567691: super() and new.instancemethod() now don't accept + keyword arguments any more (previously they accepted them, but didn't + use them). + - Bug #1331062: Fix error in UTF-7 codec. - Bug #1365916: Fix an int/long mismatch in the sorted() built-in. diff --git a/Objects/classobject.c b/Objects/classobject.c index bbd4c6d8f53c..64f524361816 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -2211,6 +2211,8 @@ instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) PyObject *self; PyObject *classObj = NULL; + if (!_PyArg_NoKeywords("instancemethod", kw)) + return NULL; if (!PyArg_UnpackTuple(args, "instancemethod", 2, 3, &func, &self, &classObj)) return NULL; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index d6e678027689..14d9c8e3fe3e 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -5706,6 +5706,8 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds) PyObject *obj = NULL; PyTypeObject *obj_type = NULL; + if (!_PyArg_NoKeywords("super", kwds)) + return -1; if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) return -1; if (obj == Py_None)