Commit 18624392 authored by Jeremy Hylton's avatar Jeremy Hylton

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?
parent 12774568
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
static char Missing_module_documentation[] = static char Missing_module_documentation[] =
"" ""
"\n$Id: Missing.c,v 1.17 2003/01/03 21:22:12 jeremy Exp $" "\n$Id: Missing.c,v 1.18 2003/05/09 19:59:31 jeremy Exp $"
; ;
#include "ExtensionClass.h" #include "ExtensionClass.h"
...@@ -78,9 +78,12 @@ Missing_nonzero(PyObject *v) ...@@ -78,9 +78,12 @@ Missing_nonzero(PyObject *v)
return 0; return 0;
} }
/* XXX Why does this type offer to corece at all? */
static int static int
Missing_coerce(PyObject **pv, PyObject **pw) Missing_coerce(PyObject **pv, PyObject **pw)
{ {
if (!(*pw)->ob_type->tp_as_number)
return 1;
Py_INCREF(*pv); Py_INCREF(*pv);
Py_INCREF(*pw); Py_INCREF(*pw);
return 0; return 0;
...@@ -250,7 +253,7 @@ static PyExtensionClass MissingType = { ...@@ -250,7 +253,7 @@ static PyExtensionClass MissingType = {
0L,0L, 0L,0L,
"Represent totally unknown quantities\n" "Represent totally unknown quantities\n"
"\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" "unknown. They support all mathematical operations except\n"
"conversions by returning themselves.\n", "conversions by returning themselves.\n",
METHOD_CHAIN(NULL) METHOD_CHAIN(NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment