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

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

index e9286b0e6a202d740e809e748721e64227ff9369..b108395269267da366e27503bd1547edb3951353 100644 (file)
@@ -2142,6 +2142,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 b28eac6f5d83ae160c62e0427903215b85f89842..23b9bbb77108c201785b1a130a5a79b723bdfe2a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's New in Python 2.6 alpha 1?
 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).
+
 - Fix a bug in the parser's future statement handling that led to "with"
   not being recognized as a keyword after, e.g., this statement:
   from __future__ import division, with_statement
index e739cc6141e27bce24ba15a4533580d60a678b16..7680a3d6d0a20dda1d3e51f01298ea6039417d5b 100644 (file)
@@ -2256,6 +2256,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 6edd455ffb1d9a2ca5e3d175ba4cc4fdebf08bb4..4d99f7d67f9b460c795076553a7e1a939b66217a 100644 (file)
@@ -5762,6 +5762,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)