[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees - BucketTemplate.c:1.16

Tim Peters tim.one@comcast.net
Fri, 28 Jun 2002 02:40:46 -0400


Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv344

Modified Files:
	BucketTemplate.c 
Log Message:
update_from_seq():  The test
    if (!n == 2)
can never succeed, because "!" binds more tightly than "==".  A core dump
was the result.  Fixed that, via testing n != 2 instead.

testBadUpdateTupleSize():  New test to provoke the failure modes due to
the above.


=== Zope3/lib/python/Persistence/BTrees/BucketTemplate.c 1.15 => 1.16 ===
 
 /**
- ** Mapping_update()
- **
- ** Accepts a sequence of 2-tuples or any object with an items()
- ** method that returns a sequence of 2-tuples.
- **
+ ** Accepts a sequence of 2-tuples, or any object with an items()
+ ** method that returns an iterable object producing 2-tuples.
  */
-
 static int
 update_from_seq(PyObject *map, PyObject *seq)
 {
@@ -465,7 +461,7 @@
 	    else
 		break;
 	}
-	if (!PyTuple_Check(o) || !PyTuple_GET_SIZE(o) == 2) {
+	if (!PyTuple_Check(o) || PyTuple_GET_SIZE(o) != 2) {
 	    Py_DECREF(o);
 	    PyErr_SetString(PyExc_TypeError,
 			    "Sequence must contain 2-item tuples");