From: Mike Bayer Date: Mon, 24 Jul 2006 16:25:40 +0000 (+0000) Subject: [ticket:254] X-Git-Tag: rel_0_2_7~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c64a0cf738f4ce2447cbfcd7faadfe3fdf783f1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git [ticket:254] --- diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py index 5e2226e9d5..724f1c807c 100644 --- a/lib/sqlalchemy/attributes.py +++ b/lib/sqlalchemy/attributes.py @@ -573,7 +573,7 @@ class AttributeManager(object): if not isinstance(class_, type): raise repr(class_) + " is not a type" for key in dir(class_): - value = getattr(class_, key) + value = getattr(class_, key, None) if isinstance(value, InstrumentedAttribute): yield value diff --git a/test/base/attributes.py b/test/base/attributes.py index 19eedd0f69..5f555a7e60 100644 --- a/test/base/attributes.py +++ b/test/base/attributes.py @@ -251,6 +251,21 @@ class AttributesTest(PersistTest): b2.element = None assert not manager.get_history(b2, 'element').hasparent(f2) + + def testdescriptorattributes(self): + """changeset: 1633 broke ability to use ORM to map classes with unusual + descriptor attributes (for example, classes that inherit from ones + implementing zope.interface.Interface). + This is a simple regression test to prevent that defect. + """ + class des(object): + def __get__(self, instance, owner): raise AttributeError('fake attribute') + + class Foo(object): + A = des() + + manager = attributes.AttributeManager() + manager.reset_class_managed(Foo) if __name__ == "__main__": unittest.main()