DAGDA SEARCH | Back to results | Support

Message 223426 - Python tracker

Source: https://bugs.python.org/msg223426

homepage

Message223426 ➜

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 tim.peters
Recipients alexandre.vassalotti, belopolsky, eddygeek, pitrou, tim.peters
Date 2014-07-18.18:53:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405709581.89.0.391162758655.issue22005@psf.upfronthosting.co.za>
In-reply-to
Content
I have no idea what was done to pickle for Python3, but this line works for me to unpickle a Python2 protocol 2 datetime pickle under Python3, where P2 is the Python2 pickle string:

    pickle.loads(bytes(P2, encoding='latin1'), encoding='bytes')

For example,

>>> P2
'\x80\x02cdatetime\ndatetime\nq\x00U\n\x07Þ\x07\x12\r%%\x06á¸q\x01\x85q\x02Rq\x03.'
>>> pickle.loads(bytes(P2, encoding='latin1'), encoding='bytes')
datetime.datetime(2014, 7, 18, 13, 37, 37, 451000)

I don't understand the Python3 loads() docs with respect to the "encoding" and "errors" arguments, and can't guess whether this is the intended way.  It seems at best highly obscure.  But hard to argue with something that works ;-)
History
Date User Action Args
2014-07-18 18:53:01tim.peterssetrecipients: + tim.peters, belopolsky, pitrou, alexandre.vassalotti, eddygeek
2014-07-18 18:53:01tim.peterssetmessageid: <1405709581.89.0.391162758655.issue22005@psf.upfronthosting.co.za>
2014-07-18 18:53:01tim.peterslinkissue22005 messages
2014-07-18 18:53:01tim.peterscreate
Supported by The Python Software Foundation,
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements