'Get the gdb.Value for the given field within the PyObject, coping with
some python 2 versus python 3 differences.
Various libpython types are defined using the "PyObject_HEAD" and
"PyObject_VAR_HEAD" macros.
In Python 2, this these are defined so that "ob_type" and (for a var
object) "ob_size" are fields of the type in question.
In Python 3, this is defined as an embedded PyVarObject type thus:
PyVarObject ob_base;
so that the "ob_size" field is located insize the "ob_base" field, and
the "ob_type" is most easily accessed by casting back to a (PyObject*).'

def field(self, name):

    if self.is_null():
        raise NullPyObjectPtr(self)
    if (name == 'ob_type'):
        pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type())
        return pyo_ptr.dereference()[name]
    if (name == 'ob_size'):
        pyo_ptr = self._gdbval.cast(PyVarObjectPtr.get_gdb_type())
        return pyo_ptr.dereference()[name]
    return self._gdbval.dereference()[name]
