]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Define MAXINT8LEN as a constant
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 14 Jan 2021 21:31:15 +0000 (22:31 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 14 Jan 2021 21:31:15 +0000 (22:31 +0100)
psycopg3_c/psycopg3_c/types/numeric.pyx

index df37adc334835b158e2dc4987de9d429fc2b1463..693310f52cb5e48bce24182963555fc3a832d46f 100644 (file)
@@ -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)