]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #1567691: super() and new.instancemethod() now don't accept
authorGeorg Brandl <georg@python.org>
Sat, 30 Sep 2006 08:43:35 +0000 (08:43 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 30 Sep 2006 08:43:35 +0000 (08:43 +0000)
keyword arguments any more (previously they accepted them, but didn't
use them).
 (backport from rev. 52058)

Lib/test/test_descr.py
Lib/test/test_new.py
Misc/NEWS
Objects/classobject.c
Objects/typeobject.c

index 4fb3b5269b54b99f89e96f7dd0a45657adf61ac8..a31a9f0cdf7ea4d9d23adf40fd1a449fd2a100d8 100644 (file)
@@ -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..."
index 4aab1e268b06f64abd23796ec397847be448cbab..eb7a40792dc4d3525a6f05b6a31e7c7a818c6fe4 100644 (file)
@@ -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
index 73515e63115e37987833f8553c2f9e09bcba4d7d..284825e352f198d6179e2a2b66fa95d28f5f5709 100644 (file)
--- 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.
index bbd4c6d8f53c9f6206167ecf791aa693557bcacf..64f52436181687d0580c647abfaf94f31b8aabc4 100644 (file)
@@ -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;
index d6e678027689de8043a41add70db6e83edc54090..14d9c8e3fe3e7be53421daf1dc0bd1b1fcde2d07 100644 (file)
@@ -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)