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

raymond.hettinger python-checkins at python.org
Mon Apr 19 00:57:57 CEST 2010


Author: raymond.hettinger
Date: Mon Apr 19 00:57:57 2010
New Revision: 80202

Log:
Issue 8436: set.__init__ accepts keyword args

Modified:
   python/trunk/Lib/test/test_set.py
   python/trunk/Objects/setobject.c

Modified: python/trunk/Lib/test/test_set.py
==============================================================================
--- python/trunk/Lib/test/test_set.py	(original)
+++ python/trunk/Lib/test/test_set.py	Mon Apr 19 00:57:57 2010
@@ -1,3 +1,4 @@
+
 import unittest
 from test import test_support
 import gc
@@ -47,6 +48,7 @@
 
     def test_new_or_init(self):
         self.assertRaises(TypeError, self.thetype, [], 2)
+        self.assertRaises(TypeError, set().__init__, a=1)
 
     def test_uniquification(self):
         actual = sorted(self.s)

Modified: python/trunk/Objects/setobject.c
==============================================================================
--- python/trunk/Objects/setobject.c	(original)
+++ python/trunk/Objects/setobject.c	Mon Apr 19 00:57:57 2010
@@ -1987,6 +1987,8 @@
 
 	if (!PyAnySet_Check(self))
 		return -1;
+	if (PySet_Check(self) && !_PyArg_NoKeywords("set()", kwds))
+		return -1;
 	if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable))
 		return -1;
 	set_clear_internal(self);


More information about the Python-checkins mailing list