Clear Pickle `memo` in Python

Viewed 685

I am building a Server-Client model using Socket programming in Python 2.7. For sending the data(strings and File both) i am using Pickle module.Here is the error i am getting in the mid-way of the program.

Traceback (most recent call last):
  File "server.py", line 30, in <module>
     C1_pick = pickle.loads(data_ciphertext)
  File "/usr/lib/python2.7/pickle.py", line 1388, in loads
     return Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 864, in load
     dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 1162, in load_binget
     self.append(self.memo[repr(i)])
  KeyError: '101'

When I use the pickle.dumps() and pickle.loads() for the first time, it is working fine, but after that i am getting this error. Searching on the Python Doc of Pickle module I learnt that the Pickle memo needs to be cleared. Unfortunately, using:

 mypickler.memo.clear()

shows a NameError.
I want to know how to clear the Pickle memo for Python2.7(exact commands)?

0 Answers
Related