From: Daniele Varrazzo Date: Sat, 21 Nov 2020 23:08:36 +0000 (+0000) Subject: C Dumpers and Loaders attributes readable from Python X-Git-Tag: 3.0.dev0~332^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e46e62c845f8b4b2b03c7ab2ac1041e521b7e217;p=thirdparty%2Fpsycopg.git C Dumpers and Loaders attributes readable from Python --- diff --git a/psycopg3_c/psycopg3_c/adapt.pyx b/psycopg3_c/psycopg3_c/adapt.pyx index 22a19b639..dc4407f77 100644 --- a/psycopg3_c/psycopg3_c/adapt.pyx +++ b/psycopg3_c/psycopg3_c/adapt.pyx @@ -28,14 +28,26 @@ logger = logging.getLogger("psycopg3.adapt") cdef class CDumper: - cdef object src - cdef object context - cdef object connection + cdef object _src + cdef object _context + cdef object _connection def __init__(self, src: type, context: AdaptContext = None): - self.src = src - self.context = context - self.connection = _connection_from_context(context) + self._src = src + self._context = context + self._connection = _connection_from_context(context) + + @property + def src(self) -> type: + return self._src + + @property + def context(self) -> AdaptContext: + return self._context + + @property + def connection(self): + return self._connection def dump(self, obj: Any) -> bytes: raise NotImplementedError() @@ -83,14 +95,26 @@ cdef class CDumper: cdef class CLoader: - cdef impl.Oid oid - cdef object context - cdef object connection + cdef impl.Oid _oid + cdef object _context + cdef object _connection def __init__(self, oid: int, context: "AdaptContext" = None): - self.oid = oid - self.context = context - self.connection = _connection_from_context(context) + self._oid = oid + self._context = context + self._connection = _connection_from_context(context) + + @property + def oid(self) -> int: + return self._oid + + @property + def context(self) -> AdaptContext: + return self._context + + @property + def connection(self): + return self._connection cdef object cload(self, const char *data, size_t length): raise NotImplementedError()