Commits

Mike Bayer  committed 41a3e1f

- 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

  • Participants
  • Parent commits 8155138

Comments (0)

Files changed (1)

File lib/sqlalchemy/orm/session.py

                 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)
 
             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:
             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