From: Raymond Hettinger Date: Sun, 18 Apr 2010 22:57:57 +0000 (+0000) Subject: Issue 8436: set.__init__ accepts keyword args X-Git-Tag: v2.7b2~249 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35b76027f94b12911cc97f960ebbb3c137d10d2b;p=thirdparty%2FPython%2Fcpython.git Issue 8436: set.__init__ accepts keyword args --- diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index b28022be49df..0c29017a808a 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -1,3 +1,4 @@ + import unittest from test import test_support import gc @@ -47,6 +48,7 @@ class TestJointOps(unittest.TestCase): 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) diff --git a/Objects/setobject.c b/Objects/setobject.c index ab281af3f5b0..f97b0c02f4df 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1987,6 +1987,8 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds) 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);