print "Maya Data Out > %s ",pickle.loads(process.stdout.read())         
  File "C:\Python26\lib\pickle.py", line 1374, in loads                     
    return Unpickler(file).load()                                           
  File "C:\Python26\lib\pickle.py", line 858, in load                       
  File "C:\Python26\lib\pickle.py", line 994, in load_tuple                 
    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     

so I google ed the web and found most people came across with this problem and only solution the end up used is pickle.dump(file,object) and then read using pickle.load(file,obj)

but i am doing a sys.stdout write operation, and I have to read it using pickle.loads(listObject) but i keep getting the Index error... any soltion how i can fix ..

4 Years
Discussion Span
Last Post by Gribouillis

pickle.loads() works very well unless the pickle was written with a different version of python. What you can do is check the integrity of your data by sending the data together with an md5 or sha sum (see module hashlib). Your remote process must compute the checksum of the pickled data that it writes to output, and your program must compute the checksum of the received data before calling pickle.loads(). This should tell us if the error comes from pickle.loads() or not. The standard library functions are heavily tested, so the number 1 suspect is your own program.

Edited by Gribouillis


the script that reads is executed in Python 2.6 (r26:66721, Oct 2 2008, 11:35:03)
and the script that dumps is executed Python 2.6.4 (r264:75706, May 19 2011, 15:20:41)

their is a huge time gap but their is minor build difference


The pickle documentation says

The pickle serialization format is guaranteed to be backwards compatible across Python releases.

I think it means that today's python can read yesterday's pickles (see here) but not the contrary.

However, I really think you should check data integrity first. The other thing you can do is dump with the ASCII protocol 0 to see if it changes anything.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.