Or update your Python 2 code to save its data in a proper well defined language agnostic portable data format instead of a pickle. Pickles are definitely a problem. My own advice is to never use them for anything you don't mind throwing away (ie: simple caches).<br><br><div class="gmail_quote">On Tue Dec 16 2014 at 5:32:55 PM Benjamin Peterson <<a href="mailto:benjamin@python.org">benjamin@python.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On Tue, Dec 16, 2014, at 20:26, Barry Warsaw wrote:<br>
> Here's an interesting situation I am faced with as I port Mailman 3 to<br>
> Python<br>
> 3.  I haven't seen any other discussion of it, so I thought I'd post here<br>
> for<br>
> posterity.<br>
><br>
> Let's say you have a pickle created in Python 2 that is to be read in<br>
> Python<br>
> 3.  In Mailman 2, persistent mailing list data is stored in pickles.<br>
><br>
> It seems like both Python 2 types (unicode and str/bytes) get unpickled<br>
> as<br>
> Python 3 str types.<br>
<br>
You can change this by passing encoding="bytes" to pickle.loads. See<br>
<a href="https://docs.python.org/3/library/pickle.html#pickle.load" target="_blank">https://docs.python.org/3/<u></u>library/pickle.html#pickle.<u></u>load</a><br>
<br>
><br>
> * Python 2 unicode should unpickle as Python 3 str<br>
> * In Python 2, bytes are just an alias for str<br>
> * There's no way to know the intent of whether Python 2 "bytes" should be<br>
>   unpickled as Python 3 bytes or str.<br>
<br>
Yeah, this is problematic. Probably the best you can do is unpickle<br>
everything with bytes then manually decode actual string things into<br>
str.<br>
______________________________<u></u>_________________<br>
Python-porting mailing list<br>
<a href="mailto:Python-porting@python.org" target="_blank">Python-porting@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-porting" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-<u></u>porting</a><br>
</blockquote></div>