当我试图打开超过某个大小(实际上相当小(<;1MB)的搁置持久化文件时,会遇到此异常,但我不确定确切的数字在哪里。现在,我知道pickle有点像python的私生子,而shelve并没有被认为是一个特别健壮的解决方案,但是它恰好很好地解决了我的问题(理论上),我还没有找到这个异常的原因。在
Traceback (most recent call last):
File "test_shelve.py", line 27, in <module>
print len(f.keys())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shelve.py", line 101, in keys
return self.dict.keys()
SystemError: Negative size passed to PyString_FromStringAndSize
我可以不断地复制它,但我在google上找不到太多。这是一个脚本,将复制。在
^{pr2}$
如果我将深度从2更改为1,或者在Python3下运行(在修复了})时,代码“有效”。但是,键列表显然不是迭代
print
语句并使用items()
而不是{recursive_dict()
返回值时找到的一组键。在来自
shelve
文档的以下限制可能适用(重点是我的):关于错误本身:
您的代码是用
2.7.3
运行的,因此可能是一个已修复的错误。在相关问题 更多 >
编程相关推荐