From: Daniele Varrazzo Date: Sat, 14 Nov 2020 18:01:29 +0000 (+0000) Subject: Work around Py2 api of PyFloat_FromDouble in Cython X-Git-Tag: 3.0.dev0~360 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8432e27db23f321857e44cb585078156a265c8ec;p=thirdparty%2Fpsycopg.git Work around Py2 api of PyFloat_FromDouble in Cython https://github.com/cython/cython/issues/3909 --- diff --git a/psycopg3_c/psycopg3_c/types/numeric.pyx b/psycopg3_c/psycopg3_c/types/numeric.pyx index c0f6fcc24..d2e12754c 100644 --- a/psycopg3_c/psycopg3_c/types/numeric.pyx +++ b/psycopg3_c/psycopg3_c/types/numeric.pyx @@ -9,7 +9,11 @@ from psycopg3_c.endian cimport be16toh, be32toh, be64toh from cpython.long cimport PyLong_FromString, PyLong_FromLong from cpython.long cimport PyLong_FromLongLong, PyLong_FromUnsignedLong -from cpython.float cimport PyFloat_FromString, PyFloat_FromDouble +from cpython.float cimport PyFloat_FromDouble + +# work around https://github.com/cython/cython/issues/3909 +cdef extern from "Python.h": + object PyFloat_FromString(object) cdef class IntLoader(CLoader): @@ -39,10 +43,8 @@ cdef class OidBinaryLoader(CLoader): cdef class FloatLoader(CLoader): cdef object cload(self, const char *data, size_t length): - # TODO: change after https://github.com/cython/cython/issues/3909 fixed - # cdef bytes b = data - # return PyFloat_FromString(b) - return float(data) + cdef bytes b = data + return PyFloat_FromString(b) cdef class Float4BinaryLoader(CLoader):