无法使用tzinfo属性Pickle ldap3 datetime对象

时间:2017-07-01 05:13:51

标签: python pickle python-datetime ldap3

from ldap3 import Server, Connection, ALL
import pickle

server = Server('ipa.demo1.freeipa.org', get_info=ALL)
conn = Connection(server, 'uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org', 'Secret123', auto_bind=True)
entries = conn.extend.standard.paged_search('dc=demo1,dc=freeipa,dc=org', '(objectClass=person)', attributes=['cn', 'givenName', 'createtimestamp'], paged_size=5)

testlist = []

for entry in entries:
    testlist.append(entry)

output = open('data.pkl', 'wb')
pickle.dump(testlist, output)
output.close()

pkl_file = open('data.pkl', 'rb')
test2 = pickle.load(pkl_file)

pkl_file.close()

...给出

C:\Python36\python.exe C:/Users/xxxxx/Dropbox/xxx/Work/Python/CEDAR/ldaptest.py
Traceback (most recent call last):
  File "C:/Users/xxxxx/Dropbox/xxx/Work/Python/CEDAR/ldaptest.py", line 20, in <module>
    test2 = pickle.load(pkl_file)
TypeError: __init__() missing 2 required positional arguments: 'offset' and 'name'

Process finished with exit code 1

这看起来与ldap3.core.timezone.py...

有关

createtimestamp属性看起来是datetime.datetime(2017, 6, 18, 11, 13, 38, tzinfo=OffsetTzInfo(offset=0, name='UTC'))

不幸的是,这是我不知道下一步该做什么的地方......这是在使用datetime对象本身进行酸洗之前应该解决的问题吗?

我无法使用常规的Python日期时间对象重新创建它。

0 个答案:

没有答案