Skip to content

Commit ea13c7f

Browse files
committed
fix(ldapobject): allow pickling with unbound connection
Issue #587
1 parent bf53339 commit ea13c7f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Lib/ldap/ldapobject.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,10 @@ def __getstate__(self):
877877
for k,v in self.__dict__.items()
878878
if k not in self.__transient_attrs__
879879
}
880-
state['_last_bind'] = self._last_bind[0].__name__, self._last_bind[1], self._last_bind[2]
880+
if self._last_bind is None:
881+
state['_last_bind'] = None
882+
else:
883+
state['_last_bind'] = self._last_bind[0].__name__, self._last_bind[1], self._last_bind[2]
881884
return state
882885

883886
def __setstate__(self,d):
@@ -888,7 +891,8 @@ def __setstate__(self,d):
888891
else:
889892
d.setdefault('bytes_strictness', 'warn')
890893
self.__dict__.update(d)
891-
self._last_bind = getattr(SimpleLDAPObject, self._last_bind[0]), self._last_bind[1], self._last_bind[2]
894+
if self._last_bind is not None:
895+
self._last_bind = getattr(SimpleLDAPObject, self._last_bind[0]), self._last_bind[1], self._last_bind[2]
892896
self._ldap_object_lock = self._ldap_lock()
893897
self._reconnect_lock = ldap.LDAPLock(desc='reconnect lock within %s' % (repr(self)))
894898
# XXX cannot pickle file, use default trace file

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy