From e0da6e16d1801fc16f8ac5cb2d82dd21ed5538d0 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Mon, 20 Apr 2009 21:37:55 +0300 Subject: Rewrite previous patch, sane cursor close checks. bzr revid: p_christ@hol.gr-20090420183755-epdfdf6pgd6vc88m --- bin/sql_db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/sql_db.py') diff --git a/bin/sql_db.py b/bin/sql_db.py index 93e95e82bfb..256df23a1e0 100644 --- a/bin/sql_db.py +++ b/bin/sql_db.py @@ -73,7 +73,7 @@ class Cursor(object): @wraps(f) def wrapper(self, *args, **kwargs): - if not hasattr(self, '_obj'): + if not '_obj' in self.__dict__: raise psycopg2.ProgrammingError('Unable to use the cursor after having closed it') return f(self, *args, **kwargs) return wrapper @@ -91,7 +91,7 @@ class Cursor(object): self.__caller = tuple(stack()[2][1:3]) def __del__(self): - if hasattr(self.__dict__, '_obj'): + if '_obj' in self.__dict__ : if tools.config['log_level'] in (netsvc.LOG_DEBUG, netsvc.LOG_DEBUG_RPC): # Oops. 'self' has not been closed explicitly. # The cursor will be deleted by the garbage collector, -- cgit v1.2.3