From: Mike Bayer Date: Wed, 13 Aug 2008 22:49:38 +0000 (+0000) Subject: dont rely upon AttributeError to test for None X-Git-Tag: rel_0_5rc1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10aeb7346d58e5fb1fc762aa7a44574fd745b9c1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git dont rely upon AttributeError to test for None --- diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index ddf7cb51ed..c0d98ffc47 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -161,11 +161,15 @@ class Pool(object): return _ConnectionFairy(self).checkout() try: - return self._threadconns.current().checkout() + rec = self._threadconns.current() + if rec: + return rec.checkout() except AttributeError: - agent = _ConnectionFairy(self) - self._threadconns.current = weakref.ref(agent) - return agent.checkout() + pass + + agent = _ConnectionFairy(self) + self._threadconns.current = weakref.ref(agent) + return agent.checkout() def return_conn(self, record): if self._use_threadlocal and hasattr(self._threadconns, "current"):