• Kirill Smelkov's avatar
    golang_str_pickle: tests: Add pickle normalization utility · 33576c9e
    Kirill Smelkov authored
    In the next patch we will start comparing dumped pickles for bstr/ustr
    to expected golden data. However there are many irrelevant differences
    in how different pickle modules, and protocols produce them:
    
    - cPickle and pickle.py differ from where they start to count *PUT
      indices. cPickle start to count them from 1, while pickle.py from 0:
    
      In [1]: s = '123'
    
      In [2]: cPickle.dumps(s)
      Out[2]: "S'123'\np1\n."
    
      In [3]: pickle.dumps(s)
      Out[3]: "S'123'\np0\n."
    
    - sometimes unused *PUT and MEMOIZE opcodes are emitted.
      see previous item for an example.
    
    We will filter out those details and compare to golden data the
    resulting pickles after normalization, which brings pickle data into
    normalized form, which still, when loaded, will be loaded in to the same
    object as original pickle, but where there are no unused *PUT/MEMOIZE
    opcodes and where *PUT indices always start from 0.
    
    -> Add pickle_normalize utility as a preparatory step for that.
    33576c9e
golang_str_pickle_test.py 8.02 KB