Message149093
> sbt, the bug is not that the encoding is inefficient. The problem is we
> cannot unpickle bytes streams from Python 3 using Python 2.
Ah. Well you can do it using codecs.encode.
Python 3.3.0a0 (default, Dec 8 2011, 17:56:13) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle, codecs
>>>
>>> class MyBytes(bytes):
... def __reduce__(self):
... return codecs.encode, (self.decode('latin1'), 'latin1')
...
>>> pickle.dumps(MyBytes(b"hello"), 2)
b'\x80\x02c_codecs\nencode\nq\x00X\x05\x00\x00\x00helloq\x01X\x06\x00\x00\x00latin1q\x02\x86q\x03Rq\x04.'
Actually, I notice that array objects created by Python 3 are not decodable on Python 2. See Issue 13566. |
|
Date |
User |
Action |
Args |
2011-12-09 13:31:17 | sbt | set | recipients:
+ sbt, irmen, pitrou, alexandre.vassalotti, meador.inge |
2011-12-09 13:31:17 | sbt | set | messageid: <1323437477.44.0.583799811722.issue13505@psf.upfronthosting.co.za> |
2011-12-09 13:31:16 | sbt | link | issue13505 messages |
2011-12-09 13:31:16 | sbt | create | |
|