Author kmike
Recipients kmike
Date 2013-07-16.11:22:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373973767.04.0.0542870445433.issue18473@psf.upfronthosting.co.za>
In-reply-to
Content
I think REVERSE_IMPORT_MAPPING is wrong (see http://hg.python.org/cpython/file/7272ef213b7c/Lib/_compat_pickle.py#l80 ). It relies on dictionary items order and maps 'collections' module to either UserString or UserList. This makes it impossible to unpickle collections module classes pickled by Python 3.x when using Python 2.x.

>>> import collections
>>> dct = collections.defaultdict()
>>> pickle.dumps(dct, protocol=1)
b'cUserString\ndefaultdict\nq\x00)Rq\x01.'
>>> pickle.dumps(dct, protocol=2, fix_imports=False)
b'ccollections\ndefaultdict\nq\x00)Rq\x01.'

I think pickling of instances of classes from other modules could also suffer. I don't think it is a good idea to map io to cStringIO or StringIO, or to map http.server to either BaseHTTPServer, SimpleHTTPServer or CGIHTTPServer.

Originally found this issue here: https://github.com/nltk/nltk/pull/441/files#L2R67
History
Date User Action Args
2013-07-16 11:22:47kmikesetrecipients: + kmike
2013-07-16 11:22:47kmikesetmessageid: <1373973767.04.0.0542870445433.issue18473@psf.upfronthosting.co.za>
2013-07-16 11:22:47kmikelinkissue18473 messages
2013-07-16 11:22:46kmikecreate