Changeset: 85468cd07ee4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=85468cd07ee4
Modified Files:
sql/backends/monet5/UDF/pyapi/type_conversion.c
Branch: Dec2016
Log Message:
Treat NaNs as the special value they are (i.e. don't blindly cast).
diffs (21 lines):
diff --git a/sql/backends/monet5/UDF/pyapi/type_conversion.c
b/sql/backends/monet5/UDF/pyapi/type_conversion.c
--- a/sql/backends/monet5/UDF/pyapi/type_conversion.c
+++ b/sql/backends/monet5/UDF/pyapi/type_conversion.c
@@ -187,7 +187,7 @@ str pyobject_to_##type(PyObject **pyobj,
} else if (PyInt_CheckExact(ptr) || PyBool_Check(ptr)) { \
*value = (type)((PyIntObject*)ptr)->ob_ival; \
} else if (PyFloat_CheckExact(ptr)) { \
- *value = (type) ((PyFloatObject*)ptr)->ob_fval;
\
+ *value = isnan(((PyFloatObject*)ptr)->ob_fval) ? type##_nil : (type)
((PyFloatObject*)ptr)->ob_fval; \
} else if (PyString_CheckExact(ptr)) { \
return str_to_##type(((PyStringObject*)ptr)->ob_sval, 0, value); \
} else if (PyByteArray_CheckExact(ptr)) { \
@@ -238,7 +238,7 @@ str pyobject_to_##type(PyObject **pyobj,
} else if (PyBool_Check(ptr)) { \
*value = ptr == Py_True ? 1 : 0; \
} else if (PyFloat_CheckExact(ptr)) { \
- *value = (type) ((PyFloatObject*)ptr)->ob_fval;
\
+ *value = isnan(((PyFloatObject*)ptr)->ob_fval) ? type##_nil : (type)
((PyFloatObject*)ptr)->ob_fval; \
} else if (PyUnicode_CheckExact(ptr)) { \
return str_to_##type(PyUnicode_AsUTF8(ptr), 0, value); \
} else if (PyByteArray_CheckExact(ptr)) { \
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list