From 8a01ba0425823a99543dcf6f8f9b86dbac2cfd2c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 20 Jan 2006 00:53:47 +0000 Subject: [PATCH] unset attributes on an object instance just return None instead of raising attributeerror --- lib/sqlalchemy/attributes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py index f87f4de9de..29a79edd24 100644 --- a/lib/sqlalchemy/attributes.py +++ b/lib/sqlalchemy/attributes.py @@ -267,12 +267,14 @@ class AttributeManager(object): return CallableProp(self, func, obj, key, uselist, **kwargs) def get_attribute(self, obj, key, **kwargs): - """returns the value of an object's scalar attribiute.""" + """returns the value of an object's scalar attribute, or None if + its not defined on the object (since we are a property accessor, this + is considered more appropriate than raising AttributeError).""" h = self.get_history(obj, key, **kwargs) try: return h.getattr() except KeyError: - raise AttributeError(key) + return None def get_list_attribute(self, obj, key, **kwargs): """returns the value of an object's list-based attribute.""" -- 2.47.2