code: def _getfield_is_safe(oldtype, newtype, offset):
      """Checks safety of getfield for object arrays.
  
      As in _view_is_safe, we need to check that memory containing objects is not
      reinterpreted as a non-object datatype and vice versa.
  
      Parameters
      ----------
      oldtype : data-type
          Data type of the original ndarray.
      newtype : data-type
          Data type of the field being accessed by ndarray.getfield
      offset : int
          Offset of the field being accessed by ndarray.getfield
  
      Raises
      ------
      TypeError
          If the field access is invalid
  
      """
      if newtype.hasobject or oldtype.hasobject:
          if offset == 0 and newtype == oldtype:
              return
          if oldtype.names is not None:
              for name in oldtype.names:
                  if (
                      oldtype.fields[name][1] == offset
                      and oldtype.fields[name][0] == newtype
                  ):
                      return
          raise TypeError("Cannot get/set field of an object array")
      return
  
imports: from __future__ import division, absolute_import, print_function
  import re
  import sys
  import platform
  from numpy.compat import unicode
  from numpy.core.overrides import set_module
  from .multiarray import dtype, array, ndarray
label_desc: Use image node_id 9 for calling a global function with example usage: _getfield_is_safe(oldtype, newtype, offset) without return types