Merge pull request #79 from marcintustin/master

Add ability to use __getnewargs__ from protocol 2

Signed-off-by: David Aguilar <davvid@gmail.com>
tags: alphabetize to minimize potential merge conflicts

Signed-off-by: David Aguilar <davvid@gmail.com>
pickle v2: improve handling for object references

We now allow Pickle Protocol v2 __getnewargs__() to contain
references.

The unpickler uses a new strategy for handling references.
It now places Proxy objects into the referencing machinery
to break dependencies between construction arguments and
parent objects.

A final sweep is done at the end of restore() to swap proxies
for their real instances.  This allows for proper referencing
within objects returned by __getnewargs__().

Related-to: #78
Signed-off-by: David Aguilar <davvid@gmail.com>
tests: add a Pickle v2 cyclical reference test

Related-to: #78
Signed-off-by: David Aguilar <davvid@gmail.com>
tests: fix typos

Signed-off-by: David Aguilar <davvid@gmail.com>
unpickler: more Pickle v2 referencing improvements

We now support cyclical references inside of lists when using
Pickle Protocol v2.

Related-to: #78
Signed-off-by: David Aguilar <davvid@gmail.com>
Add further pickle protocol 2 support:
- verifies setstate is called
- if no setstate, but getstate exists, only replace instance with state if there is no newargs;
  if there is newargs, instance should not be an empty shell
- if no newargs or setstate, adds special case handling for state as dict or 2-tuple of (dict, dict) or (None, dict)
  such that those dicts are used as a source for setattr
- No tests or code added to implemet/verify __reduce__ or __reduce_ex__ support