From: Daniele Varrazzo Date: Sun, 10 Jan 2021 03:53:24 +0000 (+0100) Subject: Avoid local import raising exception in text encoder X-Git-Tag: 3.0.dev0~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=754c5b062fc97ebe5da7adb15fdfa60cebe93792;p=thirdparty%2Fpsycopg.git Avoid local import raising exception in text encoder --- diff --git a/psycopg3_c/psycopg3_c/types/text.pyx b/psycopg3_c/psycopg3_c/types/text.pyx index 5070f5aae..8f85fa536 100644 --- a/psycopg3_c/psycopg3_c/types/text.pyx +++ b/psycopg3_c/psycopg3_c/types/text.pyx @@ -17,6 +17,8 @@ from cpython.unicode cimport ( ) from psycopg3_c.pq cimport libpq, Escaping, _buffer_as_string_and_size + +from psycopg3 import errors as e from psycopg3.encodings import pg2py cdef extern from "Python.h": @@ -88,8 +90,7 @@ cdef class StringDumper(_StringDumper): # Like the binary dump, but check for 0, or the string will be truncated cdef const char *buf = PyByteArray_AS_STRING(rv) if NULL != memchr(buf + offset, 0x00, size): - from psycopg3 import DataError - raise DataError( + raise e.DataError( "PostgreSQL text fields cannot contain NUL (0x00) bytes" ) return size