From: Albert N Date: Thu, 16 Oct 2025 16:55:31 +0000 (+0000) Subject: fix X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58c033a4813c2be3a105fff56669c6a6730f1773;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fix --- diff --git a/lib/sqlalchemy/engine/_row_cy.py b/lib/sqlalchemy/engine/_row_cy.py index 7e821c35fa..6fea91ceee 100644 --- a/lib/sqlalchemy/engine/_row_cy.py +++ b/lib/sqlalchemy/engine/_row_cy.py @@ -51,9 +51,6 @@ if not cython.compiled: def PyTuple_SET_ITEM(tup, idx, item): # type: ignore tup[idx] = item - def _getstate_impl(cls: object) -> dict: - return {"_parent": cls._parent, "_data": cls._data} - def _apply_processors( proc: _ProcessorsType, data: Sequence[Any] ) -> Tuple[Any, ...]: @@ -167,22 +164,31 @@ class BaseRow: object.__setattr__(self, "_key_to_index", key_to_index) object.__setattr__(self, "_data", data) - def __reduce__(self) -> Tuple[Any, Any]: - return ( - rowproxy_reconstructor, - (self.__class__, self._getstate_impl()), - ) - if cython.compiled: def __getstate__(self) -> Dict[str, Any]: return self._getstate_impl() + def __reduce__(self) -> Tuple[Any, Any]: + return ( + rowproxy_reconstructor, + (self.__class__, self._getstate_impl()), + ) + else: def __getstate__(self) -> Dict[str, Any]: return {"_parent": self._parent, "_data": self._data} + def __reduce__(self) -> Tuple[Any, Any]: + return ( + rowproxy_reconstructor, + ( + self.__class__, + {"_parent": self._parent, "_data": self._data}, + ), + ) + def __setstate__(self, state: Dict[str, Any]) -> None: parent = state["_parent"] self._set_attrs(parent, parent._key_to_index, state["_data"])