[ZODB-Dev] Towards ZODB on Python 3
Jim Fulton
jim at zope.com
Sun Mar 10 15:55:03 UTC 2013
On Sun, Mar 10, 2013 at 11:25 AM, Tres Seaver <tseaver at palladion.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 03/10/2013 09:19 AM, Jim Fulton wrote:
...
>> I think the fix is pretty straightforward.
>>
>> In the default __setstate__ provided by Persistent, and when loading
>> non-persistent instances:
>>
>> - On Python 2, ASCII encode unicode attribute names.
>>
>> - On Python 3, ASCII decode byte attribute names.
>>
>> The same transformation is necessary when looking up global names.
>
> Hmm, if zodbpickle has to handle the issue for non-persistent instances
> and global names, wouldn't it be simpler to make it handle persistent
> instances too?
No. It can't know when a key is going to be used for a
persistent attribute name.
> It can examine the stack inside 'load_dict' to figure out
> that the context is an instance, right?
Ugh. What stack?
It would be much simpler to handle this in __setstate__ (or the equivalent).
This isn't exactly a lot of code.
Jim
--
Jim Fulton
http://www.linkedin.com/in/jimfulton
Jerky is better than bacon! http://zo.pe/Kqm
More information about the ZODB-Dev
mailing list