From ded4e1d76b634b94a161bc91a3b4eb9d8777332b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20de=20Menten?= Date: Sun, 14 Feb 2010 21:21:40 +0000 Subject: - fix C version of rowproxy pickling so that it pickles to the same format as the Python version. - changelog my earlier processor optimization work --- lib/sqlalchemy/engine/base.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'lib/sqlalchemy/engine/base.py') diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 4dc9665c0..ff475ee3d 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1596,21 +1596,16 @@ def _proxy_connection_cls(cls, proxy): # This reconstructor is necessary so that pickles with the C extension or # without use the same Binary format. -# We need a different reconstructor on the C extension so that we can -# add extra checks that fields have correctly been initialized by -# __setstate__. try: - from sqlalchemy.cresultproxy import rowproxy_reconstructor - - # this is a hack so that the reconstructor function is pickled with the - # same name as without the C extension. - # BUG: It fails for me if I run the "python" interpreter and - # then say "import sqlalchemy": - # TypeError: 'builtin_function_or_method' object has only read-only attributes (assign to .__module__) - # However, if I run the tests with nosetests, it succeeds ! - # I've verified with pdb etc. that this is the case. - #rowproxy_reconstructor.__module__ = 'sqlalchemy.engine.base' + # We need a different reconstructor on the C extension so that we can + # add extra checks that fields have correctly been initialized by + # __setstate__. + from sqlalchemy.cresultproxy import safe_rowproxy_reconstructor + # The extra function embedding is needed so that the reconstructor function + # has the same signature whether or not the extension is present. + def rowproxy_reconstructor(cls, state): + return safe_rowproxy_reconstructor(cls, state) except ImportError: def rowproxy_reconstructor(cls, state): obj = cls.__new__(cls) -- cgit v1.2.1