This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients alexandre.vassalotti, belopolsky, lemburg, pitrou
Date 2010-06-28.00:43:07
SpamBayes Score 1.7569698e-07
Marked as misclassified No
Message-id <1277685790.99.0.096615985495.issue5180@psf.upfronthosting.co.za>
In-reply-to
Content
It looks like I was able to get to the root of the problem.  I am attaching two files that demonstrate the issue:


==> pickle-bug.py <==
import pickle
import sys
class Bug:
    pass
bug = Bug()
f = open(sys.argv[1], 'w')
pickle.Pickler(f, protocol=0).dump(bug)
f.close()

==> unpickle-bug.py <==
import pickle
import sys
class Bug:
    pass
bug = pickle._Unpickler(open(sys.argv[1], 'rb')).load() # works
print(bug)
bug = pickle.Unpickler(open(sys.argv[1], 'rb')).load() # doesn't
print(bug)

$ python2 pickle-bug.py /tmp/bug.pkl
$ python3 unpickle-bug.py /tmp/bug.pkl
<__main__.Bug object at 0x1006b6f40>
Traceback (most recent call last):
  File "unpickle-bug.py", line 7, in <module>
    bug = pickle.Unpickler(open(sys.argv[1], 'rb')).load() # doesn't
_pickle.UnpicklingError: bad pickle data


The problematic pickle is really small, so I hope I'll report that I have a fix soon.

    0: (    MARK
    1: i        INST       '__main__ Bug' (MARK at 0)
   15: p    PUT        0
   18: (    MARK
   19: d        DICT       (MARK at 18)
   20: p    PUT        1
   23: b    BUILD
   24: .    STOP
highest protocol among opcodes = 0
History
Date User Action Args
2010-06-28 00:43:11belopolskysetrecipients: + belopolsky, lemburg, pitrou, alexandre.vassalotti
2010-06-28 00:43:10belopolskysetmessageid: <1277685790.99.0.096615985495.issue5180@psf.upfronthosting.co.za>
2010-06-28 00:43:09belopolskylinkissue5180 messages
2010-06-28 00:43:08belopolskycreate