From: Mike Bayer Date: Fri, 29 Aug 2014 20:32:08 +0000 (-0400) Subject: - need to use safe_discard() at least in _restore_snapshot(), let's use it X-Git-Tag: rel_1_0_0b1~205^2~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=41a3e1fd99f651e4a3f534c57d18ad56241fd790;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - need to use safe_discard() at least in _restore_snapshot(), let's use it everywhere in Session since the optimized one only applies to loading --- diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 52873eb341..13afcb3574 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -269,7 +269,7 @@ class SessionTransaction(object): del s.key for s, (oldkey, newkey) in self._key_switches.items(): - self.session.identity_map.discard(s) + self.session.identity_map.safe_discard(s) s.key = oldkey self.session.identity_map.replace(s) @@ -1394,7 +1394,7 @@ class Session(_SessionClassMethods): self._new.pop(state) state._detach() elif self.identity_map.contains_state(state): - self.identity_map.discard(state) + self.identity_map.safe_discard(state) self._deleted.pop(state, None) state._detach() elif self.transaction: @@ -1464,7 +1464,7 @@ class Session(_SessionClassMethods): if self._enable_transaction_accounting and self.transaction: self.transaction._deleted[state] = True - self.identity_map.discard(state) + self.identity_map.safe_discard(state) self._deleted.pop(state, None) state.deleted = True