From 95949db715ff54be01bfd260a51903ede60597ae Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 1 May 2015 12:06:34 -0400 Subject: - Repair _reinstall_default_lookups to also flip the _extended flag off again so that test fixtures setup/teardown instrumentation as expected - clean up test_extendedattr.py and fix it to no longer leak itself outside by ensuring _reinstall_default_lookups is always called, part of #3408 - Fixed bug where when using extended attribute instrumentation system, the correct exception would not be raised when :func:`.class_mapper` were called with an invalid input that also happened to not be weak referencable, such as an integer. fixes #3408 --- lib/sqlalchemy/ext/instrumentation.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/ext/instrumentation.py') diff --git a/lib/sqlalchemy/ext/instrumentation.py b/lib/sqlalchemy/ext/instrumentation.py index 024136661..30a0ab7d7 100644 --- a/lib/sqlalchemy/ext/instrumentation.py +++ b/lib/sqlalchemy/ext/instrumentation.py @@ -166,7 +166,13 @@ class ExtendedInstrumentationRegistry(InstrumentationFactory): def manager_of_class(self, cls): if cls is None: return None - return self._manager_finders.get(cls, _default_manager_getter)(cls) + try: + finder = self._manager_finders.get(cls, _default_manager_getter) + except TypeError: + # due to weakref lookup on invalid object + return None + else: + return finder(cls) def state_of(self, instance): if instance is None: @@ -392,6 +398,7 @@ def _reinstall_default_lookups(): manager_of_class=_default_manager_getter ) ) + _instrumentation_factory._extended = False def _install_lookups(lookups): -- cgit v1.2.1