From: Daniele Varrazzo Date: Thu, 14 Jan 2021 21:31:15 +0000 (+0100) Subject: Define MAXINT8LEN as a constant X-Git-Tag: 3.0.dev0~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7cbf04e258c500c8e62d93d8fd46c3962838fe0;p=thirdparty%2Fpsycopg.git Define MAXINT8LEN as a constant --- diff --git a/psycopg3_c/psycopg3_c/types/numeric.pyx b/psycopg3_c/psycopg3_c/types/numeric.pyx index df37adc33..693310f52 100644 --- a/psycopg3_c/psycopg3_c/types/numeric.pyx +++ b/psycopg3_c/psycopg3_c/types/numeric.pyx @@ -30,12 +30,11 @@ cdef extern from "Python.h": # defined in numutils.c cdef extern from *: """ -#define MAXINT8LEN 20 int pg_lltoa(int64_t value, char *a); """ - int MAXINT8LEN int pg_lltoa(int64_t value, char *a) +DEF MAXINT8LEN = 20 # @cython.final # TODO? causes compile warnings cdef class IntDumper(CDumper): @@ -116,7 +115,7 @@ cdef class IntLoader(CLoader): if length > MAXINT8LEN: raise ValueError("string too big for an int") - cdef char[21] buf # MAXINT8LEN + 1 + cdef char[MAXINT8LEN + 1] buf memcpy(buf, data, length) buf[length] = 0 return PyLong_FromString(buf, NULL, 10)