From dbe961215a2cc9d9ef60aadabe9dc2fc94493e0d Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 18 Apr 2010 23:03:16 +0000 Subject: [PATCH] Issue 8436: set.__init__ accepts keyword args --- Lib/test/test_set.py | 1 + Objects/setobject.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index 2b43a1614b..3dde82fc92 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -49,6 +49,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 d2a55fc313..36afeb3780 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1978,6 +1978,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); -- 2.40.0