Fix get_attribute python implementation when a boolean value is returned.

This fixes issue #5955.