Commit fc017119 authored by Georg Brandl's avatar Georg Brandl

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)
parent 843f3553
...@@ -2142,6 +2142,13 @@ def supers(): ...@@ -2142,6 +2142,13 @@ def supers():
veris(Sub.test(), Base.aProp) 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(): def inherits():
if verbose: print "Testing inheritance from basic types..." if verbose: print "Testing inheritance from basic types..."
......
...@@ -57,6 +57,14 @@ except TypeError: ...@@ -57,6 +57,14 @@ except TypeError:
else: else:
raise TestFailed, "dangerous instance method creation allowed" 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 # 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 # 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 # (by accident?) while in Jython, `c' is local. The intent of the test
......
...@@ -12,6 +12,10 @@ What's New in Python 2.5.1c1? ...@@ -12,6 +12,10 @@ What's New in Python 2.5.1c1?
Core and builtins 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" - 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: not being recognized as a keyword after, e.g., this statement:
from __future__ import division, with_statement from __future__ import division, with_statement
......
...@@ -2256,6 +2256,8 @@ instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) ...@@ -2256,6 +2256,8 @@ instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw)
PyObject *self; PyObject *self;
PyObject *classObj = NULL; PyObject *classObj = NULL;
if (!_PyArg_NoKeywords("instancemethod", kw))
return NULL;
if (!PyArg_UnpackTuple(args, "instancemethod", 2, 3, if (!PyArg_UnpackTuple(args, "instancemethod", 2, 3,
&func, &self, &classObj)) &func, &self, &classObj))
return NULL; return NULL;
......
...@@ -5762,6 +5762,8 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -5762,6 +5762,8 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
PyObject *obj = NULL; PyObject *obj = NULL;
PyTypeObject *obj_type = NULL; PyTypeObject *obj_type = NULL;
if (!_PyArg_NoKeywords("super", kwds))
return -1;
if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj))
return -1; return -1;
if (obj == Py_None) if (obj == Py_None)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment