From 0c64a8ab5c05eb830f40980ded7fab541b1ca932 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 10 Jul 2007 20:38:40 +0000 Subject: [PATCH] fixed small expunge() bug where object might not be present in session --- lib/sqlalchemy/orm/unitofwork.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index c6b0b2689c..5f28d28e76 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -108,7 +108,7 @@ class UnitOfWork(object): echo = logging.echo_property() def _remove_deleted(self, obj): - if hasattr(obj, "_instance_key"): + if hasattr(obj, "_instance_key") and obj._instance_key in self.identity_map: del self.identity_map[obj._instance_key] try: self.deleted.remove(obj) -- 2.47.2