[Zodb-checkins] CVS: ZODB3/ExtensionClass/src - Missing.c:1.18

Jeremy Hylton jeremy at zope.com
Fri May 9 16:59:32 EDT 2003


Update of /cvs-repository/ZODB3/ExtensionClass/src
In directory cvs.zope.org:/tmp/cvs-serv8153

Modified Files:
	Missing.c 
Log Message:
Don't coerce Missing.Value to a non-numeric type.

Fixes crash reported by Tres Seaver.  Missing.Value offered to coerce
itself to unicode.  unicode_compare() blew up because it expected that
the other argument had been converted to unicode.

XXX But why does this implement coercion at all?


=== ZODB3/ExtensionClass/src/Missing.c 1.17 => 1.18 ===
--- ZODB3/ExtensionClass/src/Missing.c:1.17	Fri Jan  3 16:22:12 2003
+++ ZODB3/ExtensionClass/src/Missing.c	Fri May  9 15:59:31 2003
@@ -78,12 +78,15 @@
   return 0;
 }
 
+/* XXX Why does this type offer to corece at all? */
 static int
 Missing_coerce(PyObject **pv, PyObject **pw)
 {
-  Py_INCREF(*pv);
-  Py_INCREF(*pw);
-  return 0;
+    if (!(*pw)->ob_type->tp_as_number)
+	return 1;
+    Py_INCREF(*pv);
+    Py_INCREF(*pw);
+    return 0;
 }
 
 static PyObject *
@@ -250,7 +253,7 @@
   0L,0L,
   "Represent totally unknown quantities\n"
   "\n"
-  "Missing values are used to represent numberic quantities that are\n"
+  "Missing values are used to represent numeric quantities that are\n"
   "unknown.  They support all mathematical operations except\n"
   "conversions by returning themselves.\n",
   METHOD_CHAIN(NULL)




More information about the Zodb-checkins mailing list