• Kirill Smelkov's avatar
    go/zodbpickle: Switch to unpickle with PyDict=y mode · 1e87fe5b
    Kirill Smelkov authored
    Previously we were unpickling dicts into map[any]any and it was making a
    difference from which Python version the dict was saved: if it was saved
    from py2 with str keys, then the dict needed to be accessed with ByteString
    keys, while if it was saved from py3 with str keys, the dict needed to
    be accessed with string keys. This peculiarity is one of the reasons why
    Map test currently fails on py3_pickle3 - because there - both in the
    test and inside Map.PySetState, dictionaries are accessed via ByteString
    keys which works only wrt py2-saved data.
    
    -> Fix it by switching the unpickler to work in PyDict=y mode(*) which
    results in dicts unpickled as ogórek.Dict instead of map[any]any
    with the ogórek.Dict considering ByteString to be equal to both string and Bytes
    with the same underlying content. This allows programs to access Dict via
    string/bytes keys following Python3 model, while still being able to handle
    dictionaries generated from under Python2.
    
    For ZODB/go this is change in behaviour exposed to outside. However
    there is currently only one known ZODB/go user - WCFS in Wendelin.core -
    and that user will be updated correspondingly as well.
    
    The change fixes the following failure in go/zodb tests
    
        --- FAIL: TestPersistentMapListLoad/py3_pickle3 (0.70s)
            persistent_x_test.go:57: persistent.mapping.PersistentMapping(0000000000000000): activate: pysetstate: noone of ["data" "_container"] is present in state dict
    
    but one more remains there which will be addressed in the next patch.
    
    (*) see https://github.com/kisielk/og-rek/pull/75 for details.
    1e87fe5b
zeo.go 14.5 KB