]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Avoid local import raising exception in text encoder
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 10 Jan 2021 03:53:24 +0000 (04:53 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 10 Jan 2021 03:54:42 +0000 (04:54 +0100)
psycopg3_c/psycopg3_c/types/text.pyx

index 5070f5aae89ac745ca08dafa52b520e27135ae74..8f85fa536a8f12247914eba1b4aa6f85618a7246 100644 (file)
@@ -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