Ensure the GIL is held while all python is executed.

This is required for Python on Ubuntu 13.10 where the dict
destruction requires an valid threadstate pointer.
Refs #8304
Extract the "real" shared_ptr instance from Python objects

The standard boost::python::extract<shared_ptr> actually
creates a new shared_ptr from the original and embeds
a custom deleter to decref the Python object it was
embedded into. As the C++ side is the one that created
the shared_ptr originally we just want the same one back.
Refs #8304