Message149104
> I suggest that array.array be changed in Python 2 to allow unicode strings
> as a typecode or that pickle detects array.array being called and fixes
> the call.
Interestingly, py3 does understand arrays pickled by py2. This appears to be because py2 pickles str using BINSTRING or SHORT_BINSTRING which will unpickle as str on py2 and py3. py3 pickles str using BINUNICODE which will unpickle as unicode on py2 and str on py3.
I think it would be better to fix this in py3 if possible, but that does not look easy: modifying array.__reduce_ex__ alone would not be enough.
The only thing I can think of is for py3 to grow a "_binstr" type which only supports ascii strings and is special-cased by pickle to be pickled using BINSTRING. Then array.__reduce_ex__ could be something like:
def __reduce_ex__(self, protocol):
if protocol <= 2:
return array.array, (_binstr(self.typecode), list(self))
else:
... |
|
Date |
User |
Action |
Args |
2011-12-09 15:27:03 | sbt | set | recipients:
+ sbt, pitrou, alexandre.vassalotti, Ramchandra Apte |
2011-12-09 15:27:03 | sbt | set | messageid: <1323444423.89.0.587830819909.issue13566@psf.upfronthosting.co.za> |
2011-12-09 15:27:03 | sbt | link | issue13566 messages |
2011-12-09 15:27:02 | sbt | create | |
|