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

raymond.hettinger python-checkins at python.org
Wed Jun 11 02:44:48 CEST 2008


Author: raymond.hettinger
Date: Wed Jun 11 02:44:47 2008
New Revision: 64101

Log:
Handle the case with zero arguments.



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	Wed Jun 11 02:44:47 2008
@@ -104,6 +104,12 @@
             self.assertEqual(self.thetype('abcba').intersection(C('ccb')), set('bc'))
             self.assertEqual(self.thetype('abcba').intersection(C('ef')), set(''))
             self.assertEqual(self.thetype('abcba').intersection(C('cbcf'), C('bag')), set('b'))
+        s = self.thetype('abcba')
+        z = s.intersection()
+        if self.thetype == frozenset():
+            self.assertEqual(id(s), id(z))
+        else:
+            self.assertNotEqual(id(s), id(z))
 
     def test_isdisjoint(self):
         def f(s1, s2):

Modified: python/trunk/Objects/setobject.c
==============================================================================
--- python/trunk/Objects/setobject.c	(original)
+++ python/trunk/Objects/setobject.c	Wed Jun 11 02:44:47 2008
@@ -1312,6 +1312,9 @@
 	Py_ssize_t i;
 	PyObject *result = (PyObject *)so;
 
+	if (PyTuple_GET_SIZE(args) == 0)
+		return set_copy(so);
+
 	Py_INCREF(so);
 	for (i=0 ; i<PyTuple_GET_SIZE(args) ; i++) {
 		PyObject *other = PyTuple_GET_ITEM(args, i);


More information about the Python-checkins mailing list