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 sbt
Recipients Ramchandra Apte, alexandre.vassalotti, pitrou, sbt
Date 2011-12-09.15:27:02
SpamBayes Score 3.441827e-06
Marked as misclassified No
Message-id <1323444423.89.0.587830819909.issue13566@psf.upfronthosting.co.za>
In-reply-to
Content
> 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:
      ...
History
Date User Action Args
2011-12-09 15:27:03sbtsetrecipients: + sbt, pitrou, alexandre.vassalotti, Ramchandra Apte
2011-12-09 15:27:03sbtsetmessageid: <1323444423.89.0.587830819909.issue13566@psf.upfronthosting.co.za>
2011-12-09 15:27:03sbtlinkissue13566 messages
2011-12-09 15:27:02sbtcreate