diff --git a/Lib/ldap/ldapobject.py b/Lib/ldap/ldapobject.py index 8fa71c3..e55d795 100644 --- a/Lib/ldap/ldapobject.py +++ b/Lib/ldap/ldapobject.py @@ -1167,6 +1167,11 @@ class ReconnectLDAPObject(SimpleLDAPObject): SimpleLDAPObject.start_tls_s(self) # Repeat last simple or SASL bind self._apply_last_bind() + except LDAPError as exc: + # Ensure self._l is not in a not fully initialized state + SimpleLDAPObject.unbind_s(self) + try: + raise exc except (ldap.SERVER_DOWN,ldap.TIMEOUT): if __debug__ and self._trace_level>=1: self._trace_file.write('*** %s reconnect to %s failed\n' % ( @@ -1178,7 +1183,6 @@ class ReconnectLDAPObject(SimpleLDAPObject): if __debug__ and self._trace_level>=1: self._trace_file.write('=> delay %s...\n' % (retry_delay)) time.sleep(retry_delay) - SimpleLDAPObject.unbind_s(self) else: if __debug__ and self._trace_level>=1: self._trace_file.write('*** %s reconnect to %s successful => repeat last operation\n' % (