Simplify shared_ptr extraction from Python object

Also avoid using the raw Python C API in favour of the boost python wrappers to
ensure that the reference counting is dealt with properly
Refs #9513
Fix PythonAlgorithmTraitsTest

The object returned from the factory now has been downcast to the
correct type in Python meaning in the tests the methods are bypassing
the base class in some cases.
Refs #9513
Wrap the boost::python deleter with one that locks the GIL first.

For objects that might be deleted when the GIL is not already held
already, e.g. live data or a sub algorithm of another C++ algorithm, this
avoids a segfault on later versions of Python 2.7.
Refs #9513
Merge remote-tracking branch 'origin/bugfix/9513_pyobj_del_not_called'