c extensions need to call string format on ints too

Issue #2432 resolved
Mike Bayer repo owner created an issue

else Sqlite fails as it returns ints for whole numbers

diff -r 57868f587ee9f1e35661e8dfadc0b73740300da6 lib/sqlalchemy/cextension/processors.c
--- a/lib/sqlalchemy/cextension/processors.c    Mon Mar 12 13:35:27 2012 -0700
+++ b/lib/sqlalchemy/cextension/processors.c    Tue Mar 13 13:29:30 2012 -0700
@@ -342,23 +342,18 @@
     if (value == Py_None)
         Py_RETURN_NONE;

-    if (PyFloat_CheckExact(value)) {
-        /* Decimal does not accept float values directly */
-        args = PyTuple_Pack(1, value);
-        if (args == NULL)
-            return NULL;
+    args = PyTuple_Pack(1, value);
+    if (args == NULL)
+        return NULL;

-        str = PyString_Format(self->format, args);
-        Py_DECREF(args);
-        if (str == NULL)
-            return NULL;
+    str = PyString_Format(self->format, args);
+    Py_DECREF(args);
+    if (str == NULL)
+        return NULL;

-        result = PyObject_CallFunctionObjArgs(self->type, str, NULL);
-        Py_DECREF(str);
-        return result;
-    } else {
-        return PyObject_CallFunctionObjArgs(self->type, value, NULL);
-    }
+    result = PyObject_CallFunctionObjArgs(self->type, str, NULL);
+    Py_DECREF(str);
+    return result;
 }

 static void

Comments (2)

  1. Log in to comment