summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-09-30 08:43:30 (GMT)
committerGeorg Brandl <georg@python.org>2006-09-30 08:43:30 (GMT)
commit5d59c0983431b0b7d3929dd2851b00e20e1d8c15 (patch)
tree0ee7023af580fab706ed5f0c7bfeb14f99af0230
parent8c6674511b7fd0cafcdf00011eb91c3216be094f (diff)
downloadcpython-5d59c0983431b0b7d3929dd2851b00e20e1d8c15.zip
cpython-5d59c0983431b0b7d3929dd2851b00e20e1d8c15.tar.gz
cpython-5d59c0983431b0b7d3929dd2851b00e20e1d8c15.tar.bz2
Patch #1567691: super() and new.instancemethod() now don't accept
keyword arguments any more (previously they accepted them, but didn't use them).
-rw-r--r--Lib/test/test_descr.py7
-rw-r--r--Lib/test/test_new.py8
-rw-r--r--Misc/NEWS4
-rw-r--r--Objects/classobject.c2
-rw-r--r--Objects/typeobject.c2
5 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index e9286b0..b108395 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -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..."
diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py
index 4aab1e2..eb7a407 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 b28eac6..23b9bbb 100644
--- 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
diff --git a/Objects/classobject.c b/Objects/classobject.c
index e739cc6..7680a3d 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -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;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 6edd455..4d99f7d 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -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)