From db01767acf4cb002995a3609061a45ca90cde573 Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Jun 21 2017 08:24:39 +0000 Subject: py3: LDAPClient: remove __del__ method in py3 we are receiving ugly tracebacks due __del__ method that should be used very carefully or never. Due tracebacks, this doesn't work and context manager should be used for reliable connection termination. Exception ignored in: Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/ipapython/ipaldap.py", line 1057, in __del__ File "/usr/lib/python3.5/site-packages/ipaserver/plugins/ldap2.py", line 123, in close File "/usr/lib/python3.5/site-packages/ipalib/backend.py", line 94, in isconnected NameError: name 'hasattr' is not defined Reviewed-By: Stanislav Laznicka --- diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index f4f4bc5..b9fcf51 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -1054,9 +1054,6 @@ class LDAPClient(object): reason=_('objectclass %s not found') % oc) return [unicode(a).lower() for a in list(set(allowed_attributes))] - def __del__(self): - self.close() - def __enter__(self): return self