title: Possible to Unpickle class instances after being converted from old to new style?
body: <p>In python, is it possible to unpickle objects that were pickled as old-style python classes after being converted to new-style ones? (Ie, objects with different "class signatures"). * </p>
  
  <p>For example, imagine some instances were saved as:</p>
  
  <pre><code>class foo: # old style
  </code></pre>
  
  <p>and then a few more objects were pickled after the class was changed to inherit from object:</p>
  
  <pre><code>class foo(object): # new style
  </code></pre>
  
  <p>Objects that are <code>pickle.dump</code>'ed with one can be <code>pickle.load</code>'ed by the same style class, but neither one will load both. I think that the strategy used by pickle changes based on the inheritance (the class that inherits from object has a __reduce__ method automatically defined, but the one without inheritance doesn't). When trying to load a with-inheritance old-style pickle from code without inheritance (old-style definition), I get the same argument error as seen in this <a href="https://stackoverflow.com/q/3855428/218118">SO question</a>; even though the second argument is redundant, it still changes the "class signature" and expected arguments, and prevents loading. To solve this, I'd be happy to write an unpickler, although I'm afraid it may involve two separate sub-classed unpicklers <a href="http://docs.python.org/library/pickle.html#subclassing-unpicklers" rel="nofollow noreferrer">a la the docs</a>... If I knew how to correctly unpickle each one I'd be fine doing that.</p>
  
  <p>A little background on my situation... I'm using a TrialHandler class to save and reload button presses and reaction times for behavioral psychology experiments. We refactored the TrialHandler class to inherit from a more abstract, baseTrialHandler, but in doing so temporarily changed the class signature to inherit from <em>object</em>. However, we couldn't unpickle older trial_handler files, so it was changed back. I'd like to look at data from the same experiment that was run with both versions of the trial handler, and so want to unpickle both types of saved log file in the same script.</p>
  
  <p>Alternatively, if I can't write a custom unpickler that will unpickle both objects, is there another way to serialize them? I tried dumping straight to yaml, but it looks like I'll have to register the class as something that can be yaml'ized, anyway. </p>
  
  <p>A full <a href="https://groups.google.com/forum/?fromgroups#!topic/psychopy-dev/NEd-pm4lXOk" rel="nofollow noreferrer">description of the problem</a> with specific errors is on the PsychoPy mailing list. Any blog posts explaining the details intermediate pickling, or even python inheritance, would be most welcome; the closest I found was a good explanation of why <a href="http://nadiana.com/python-pickle-insecure" rel="nofollow noreferrer">pickling is insecure</a> describing pickling as a "simple stack-based virtual machine", which is nice, but doesn't get me enough to figure out even the basics of unpicking myself.</p>