[Python-3000] Heaptypes

"Martin v. Löwis" martin at v.loewis.de
Thu Jul 19 02:15:30 CEST 2007


> You broke backwards compatibility this way; I think that a pickle
> produced by Python 2.x should be readable by Python 3.0.

It is, is it not?

> (I haven't decided whether to keep str8 or something like it, or
> whether to try to get rid of it completely).

I assumed the latter - and if it indeed goes away, it's certainly
a bug to ever return str8 from pickle, right?

> One possibility might be to first try to decode the STRING argument as
> utf-8, and if that fails to convert it to str8 instead. What do you
> think? I don't understand all of the changes you made in r56438,
> perhaps you can save most of them.

The question really is what bytes should be pickled as; that needs to
be decided before fixing the code. Should it be built-in (and if so,
using what code)? If not, it probably needs to go through __reduce__,
and if so, what should __reduce__ return for bytes object?

__reduce__ currently does (O(s#)) with (ob_type, ob_bytes, ob_size).
Now, s# creates a Unicode object, and the pickling fails to round-trip
correctly.

If __reduce__ returns a Unicode object, what encoding should be assumed?
(which then needs to be symmetric with bytes())

If __reduce__ returns a str8 object, you will have to keep str8 (or
else you cannot pickle bytes).

Regards,
Martin




More information about the Python-3000 mailing list