Prevent use of NaN with Oracle numbers since it produces corrupt data
(https://github.com/oracle/python-cx_Oracle/issues/91).
This commit is contained in:
parent
9311ab9c4e
commit
c5fab177f9
@ -248,6 +248,12 @@ static int PythonFloatToOracleNumber(
|
||||
sword status;
|
||||
|
||||
doubleValue = PyFloat_AS_DOUBLE(pythonValue);
|
||||
if (isnan(doubleValue)) {
|
||||
PyErr_SetString(g_DatabaseErrorException,
|
||||
"value is not a number (NaN) and cannot be used in Oracle "
|
||||
"numbers");
|
||||
return -1;
|
||||
}
|
||||
status = OCINumberFromReal(environment->errorHandle, &doubleValue,
|
||||
sizeof(double), oracleValue);
|
||||
return Environment_CheckForError(environment, status,
|
||||
|
||||
@ -18,10 +18,18 @@
|
||||
#include <datetime.h>
|
||||
#include <structmember.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <oci.h>
|
||||
#include <orid.h>
|
||||
#include <xa.h>
|
||||
|
||||
// define isnan for older versions of Visual Studio which only define _isnan
|
||||
#ifdef _WIN32
|
||||
#ifndef isnan
|
||||
#define isnan _isnan
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// validate OCI library
|
||||
#if !defined(OCI_MAJOR_VERSION) || (OCI_MAJOR_VERSION < 11) || \
|
||||
((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user