diff --git a/src/cxoTransform.c b/src/cxoTransform.c index f04aa0f..bdd8ad7 100644 --- a/src/cxoTransform.c +++ b/src/cxoTransform.c @@ -717,14 +717,12 @@ PyObject *cxoTransform_toPython(cxoTransformNum transformNum, #endif Py_DECREF(stringObj); return result; - } else if (transformNum != CXO_TRANSFORM_DECIMAL && - bytes->length <= 15) { + } else if (transformNum == CXO_TRANSFORM_DECIMAL) { + result = PyObject_CallFunctionObjArgs( + (PyObject*) cxoPyTypeDecimal, stringObj, NULL); + } else { result = PyNumber_Float(stringObj); - Py_DECREF(stringObj); - return result; } - result = PyObject_CallFunctionObjArgs( - (PyObject*) cxoPyTypeDecimal, stringObj, NULL); Py_DECREF(stringObj); return result; case CXO_TRANSFORM_OBJECT: diff --git a/test/NumberVar.py b/test/NumberVar.py index 7a60884..31de4ca 100644 --- a/test/NumberVar.py +++ b/test/NumberVar.py @@ -321,7 +321,7 @@ class TestCase(TestEnv.BaseTestCase): decimal.Decimal("-9.99999999999999e+125"), 0.0, 1e-130, -1e-130] outValues = [int("9" * 15 + "0" * 111), -int("9" * 15 + "0" * 111), - 0, decimal.Decimal("1e-130"), decimal.Decimal("-1e-130")] + 0, 1e-130, -1e-130] for inValue, outValue in zip(inValues, outValues): self.cursor.execute("select :1 from dual", (inValue,)) result, = self.cursor.fetchone() @@ -351,8 +351,8 @@ class TestCase(TestEnv.BaseTestCase): from TestNumbers where IntCol = 1""") result, = self.cursor.fetchone() - self.assertAlmostEqual(result, - decimal.Decimal("1") / decimal.Decimal("7")) + self.assertEqual(result, 1.0 / 7.0) + self.assertTrue(isinstance(result, float), "float not returned") def testStringFormat(self): "test that string format is returned properly"