开发者

Python Pickle: what can cause stack index out of range error?

I'm getting this error:

  File "C:\Python26\lib\pi开发者_开发问答ckle.py", line 1374, in loads
    return Unpickler(file).load()
  File "C:\Python26\lib\pickle.py", line 858, in load
    dispatch[key](self)
  File "C:\Python26\lib\pickle.py", line 1075, in load_obj
    k = self.marker()
  File "C:\Python26\lib\pickle.py", line 874, in marker
    while stack[k] is not mark: k = k-1
IndexError: list index out of range

Why could this be happening?


A "damaged file" is the general explanation; single most likely cause is that you forgot to open the file (in Windows) as 'rb' ("read binary") and the pickling was done with a binary protocol (i.e., any protocol except the old, slow default protocol 0, ascii only, that basically exists only for legacy purposes, makes larger files, and has several limitations).


Answer: I was trying to call pickle.loads() on the uninitialized field of a Google App Engine model.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜