Raise PoolError when putting a connection not belonging to the pool

A KeyError was raised instead.
This commit is contained in:
Daniele Varrazzo 2011-06-30 15:53:31 +01:00
parent de6f2ac387
commit 4fd5f3267b

View File

@ -115,7 +115,7 @@ class AbstractConnectionPool(object):
def _putconn(self, conn, key=None, close=False):
"""Put away a connection."""
if self.closed: raise PoolError("connection pool is closed")
if key is None: key = self._rused[id(conn)]
if key is None: key = self._rused.get(id(conn))
if not key:
raise PoolError("trying to put unkeyed connection")