From: Mike Bayer Date: Tue, 23 Apr 2013 17:23:48 +0000 (-0400) Subject: Added a conditional to the unpickling process for ORM X-Git-Tag: rel_0_8_1~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77e0a5dffe7950a729d6c16afbc70bb867af6dd8;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Added a conditional to the unpickling process for ORM mapped objects, such that if the reference to the object were lost when the object was pickled, we don't erroneously try to set up _sa_instance_state - fixes a NoneType error. --- diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index 2a3d96ae01..97b3626afc 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,15 @@ .. changelog:: :version: 0.8.1 + .. change:: + :tags: bug, orm + + Added a conditional to the unpickling process for ORM + mapped objects, such that if the reference to the object + were lost when the object was pickled, we don't + erroneously try to set up _sa_instance_state - fixes + a NoneType error. + .. change:: :tags: bug, postgresql :tickets: 2712 diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 193678c2ff..6ade91b3e0 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -272,7 +272,8 @@ class InstanceState(interfaces._InspectionAttr): # setup _sa_instance_state ahead of time so that # unpickle events can access the object normally. # see [ticket:2362] - manager.setup_instance(inst, self) + if inst is not None: + manager.setup_instance(inst, self) manager.dispatch.unpickle(self, state) def _initialize(self, key):