• Marius Gedminas's avatar
    Try to push persistentclass along · abad361f
    Marius Gedminas authored
    Problem: in Python 2 object lives in sys.modules['__builtin__'].  In
    Python 3 it lives in sys.modules['builtins'].  When we pickle object in
    Python 2 and try to load it in Python 3, we end up getting a Broken
    object placeholder because sys.modules['__builtin__'] is AWOL.
    
    I'm not sure how persistentclass.txt manages to reproduce that purely in
    Python 3, but that's what the new assertion failure I added reports.
    
    Oh, I know: old pickle protocol!
    
        Python 3.3.0 (default, Sep 29 2012, 17:14:58)
        [GCC 4.7.2] on linux
        Type "help", "copyright", "credits" or "license" for more information.
        >>> import pickle
        >>> pickle.dumps(object)
        b'\x80\x03cbuiltins\nobject\nq\x00.'
        >>> pickle.dumps(object, 1)
        b'c__builtin__\nobject\nq\x00.'
        >>> pickle.loads(_)
        <class 'object'>
    
    We need to find the mapping layer that handles __builtin__ in Python
    3.3's pickle and make sure our own ZODB.broken.find_global can do the
    same.
    abad361f