sbt <[email protected]> added the comment:
> 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:
...
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13566>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com