[Python-checkins] r53381 - in python/trunk: Lib/test/test_set.py Objects/setobject.c

raymond.hettinger python-checkins at python.org
Thu Jan 11 19:22:56 CET 2007


Author: raymond.hettinger
Date: Thu Jan 11 19:22:55 2007
New Revision: 53381
Modified:
 python/trunk/Lib/test/test_set.py
 python/trunk/Objects/setobject.c
Log:
SF #1486663 -- Allow keyword args in subclasses of set() and frozenset().
Modified: python/trunk/Lib/test/test_set.py
==============================================================================
--- python/trunk/Lib/test/test_set.py	(original)
+++ python/trunk/Lib/test/test_set.py	Thu Jan 11 19:22:55 2007
@@ -468,6 +468,16 @@
 class TestSetSubclass(TestSet):
 thetype = SetSubclass
 
+class SetSubclassWithKeywordArgs(set):
+ def __init__(self, iterable=[], newarg=None):
+ set.__init__(self, iterable)
+
+class TestSetSubclassWithKeywordArgs(TestSet):
+ 
+ def test_keywords_in_subclass(self):
+ 'SF bug #1486663 -- this used to erroneously raise a TypeError'
+ SetSubclassWithKeywordArgs(newarg=1)
+
 class TestFrozenSet(TestJointOps):
 thetype = frozenset
 
@@ -1450,6 +1460,7 @@
 test_classes = (
 TestSet,
 TestSetSubclass,
+ TestSetSubclassWithKeywordArgs, 
 TestFrozenSet,
 TestFrozenSetSubclass,
 TestSetOfSets,
Modified: python/trunk/Objects/setobject.c
==============================================================================
--- python/trunk/Objects/setobject.c	(original)
+++ python/trunk/Objects/setobject.c	Thu Jan 11 19:22:55 2007
@@ -1004,7 +1004,7 @@
 {
 	PyObject *iterable = NULL, *result;
 
-	if (!_PyArg_NoKeywords("frozenset()", kwds))
+	if (type == &PyFrozenSet_Type && !_PyArg_NoKeywords("frozenset()", kwds))
 		return NULL;
 
 	if (!PyArg_UnpackTuple(args, type->tp_name, 0, 1, &iterable))
@@ -1048,7 +1048,7 @@
 static PyObject *
 set_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-	if (!_PyArg_NoKeywords("set()", kwds))
+	if (type == &PySet_Type && !_PyArg_NoKeywords("set()", kwds))
 		return NULL;
 	
 	return make_new_set(type, NULL);


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /