At least calling PQport on a connection with multiple attempts ends up
returning a NULL instead of an empty string (libpq from Postgres 17.4).
if not self._pgconn_ptr:
raise e.OperationalError("the connection is closed")
rv = func(self._pgconn_ptr)
- assert rv is not None
- return rv
+ return rv if rv is not None else b""
def _call_int(self, func: Callable[[impl.PGconn_struct], int]) -> int:
"""
if not _ensure_pgconn(pgconn):
return NULL
cdef char *rv = func(pgconn._pgconn_ptr)
- assert rv is not NULL
- return rv
+ if rv is not NULL:
+ return rv
+ else:
+ return b""
cdef int _call_int(PGconn pgconn, conn_int_f func) except -2: