From: Daniele Varrazzo Date: Thu, 17 Dec 2020 11:50:48 +0000 (+0100) Subject: Fixed broken previous commit X-Git-Tag: 3.0.dev0~261 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e2c4272dab6af18f1a1d99c2d2a8531ab62de42;p=thirdparty%2Fpsycopg.git Fixed broken previous commit --- diff --git a/psycopg3_c/psycopg3_c/adapt.pyx b/psycopg3_c/psycopg3_c/adapt.pyx index 761ec5816..303265478 100644 --- a/psycopg3_c/psycopg3_c/adapt.pyx +++ b/psycopg3_c/psycopg3_c/adapt.pyx @@ -75,7 +75,7 @@ cdef class CDumper: else: esc = Escaping() - tmp = esc.escape_string(value) + tmp = bytes(esc.escape_string(value)) return b"'%s'" % tmp @property diff --git a/psycopg3_c/psycopg3_c/pq_cython.pyx b/psycopg3_c/psycopg3_c/pq_cython.pyx index 7f0bd9cbe..a86e540aa 100644 --- a/psycopg3_c/psycopg3_c/pq_cython.pyx +++ b/psycopg3_c/psycopg3_c/pq_cython.pyx @@ -873,6 +873,8 @@ cdef class Escaping: else: len_out = impl.PQescapeString(PyByteArray_AS_STRING(rv), ptr, length) + # shrink back or the length will be reported different + PyByteArray_Resize(rv, len_out) return memoryview(rv) def escape_bytea(self, data: "Buffer") -> memoryview: