开发者

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

开发者 https://www.devze.com 2023-01-03 19:05 出处:网络
I\'m getting this error: File \"C:\\Python26\\lib\\pi开发者_开发问答ckle.py\", line 1374, in loads

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

精彩评论

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

关注公众号