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

raymond.hettinger python-checkins at python.org
Wed Mar 21 21:34:01 CET 2007


Author: raymond.hettinger
Date: Wed Mar 21 21:33:57 2007
New Revision: 54495

Modified:
   python/trunk/Lib/test/test_set.py
   python/trunk/Objects/dictobject.c
Log:
Add test and fix for fromkeys() optional argument.

Modified: python/trunk/Lib/test/test_set.py
==============================================================================
--- python/trunk/Lib/test/test_set.py	(original)
+++ python/trunk/Lib/test/test_set.py	Wed Mar 21 21:33:57 2007
@@ -293,6 +293,9 @@
         self.assertEqual(sum(elem.hash_count for elem in d), n)
         d3 = dict.fromkeys(frozenset(d))
         self.assertEqual(sum(elem.hash_count for elem in d), n)
+        d3 = dict.fromkeys(frozenset(d), 123)
+        self.assertEqual(sum(elem.hash_count for elem in d), n)
+        self.assertEqual(d3, dict.fromkeys(d, 123))
 
 class TestSet(TestJointOps):
     thetype = set

Modified: python/trunk/Objects/dictobject.c
==============================================================================
--- python/trunk/Objects/dictobject.c	(original)
+++ python/trunk/Objects/dictobject.c	Wed Mar 21 21:33:57 2007
@@ -1186,8 +1186,8 @@
 
 		while (_PySet_NextEntry(seq, &pos, &key, &hash)) {
 			Py_INCREF(key);
-			Py_INCREF(Py_None);
-			if (insertdict(mp, key, hash, Py_None))
+			Py_INCREF(value);
+			if (insertdict(mp, key, hash, value))
 				return NULL;
 		}
 		return d;


More information about the Python-checkins mailing list