Comment 2 for bug 330999

Revision history for this message
mark.a.m (mark-a-m) wrote :

The problem here is, given the case that some callee (e.g. __del__) wants to see if aCursor contains an attribute named '_obj' hasattr calls getattr to see if it raises an exception, getattr in turn calls __getattr__ which is wrapped in checks wrapper method which uses hasattr triggering an infinite recursion.

--- sql_db.py.bak 2009-03-05 22:59:42.000000000 +0100
+++ sql_db.py 2009-03-06 00:12:34.000000000 +0100
@@ -181,9 +181,11 @@
     def rollback(self):
         return self._cnx.rollback()

- @check
     def __getattr__(self, name):
- return getattr(self._obj, name)
+ if name =='_obj':
+ raise AttributeError("No attribute named _obj")
+ else:
+ return getattr(self._obj, name)

 class ConnectionPool(object):
     def __init__(self, pool, dbname):