code: def safe_expandvars(value):
      
      if isinstance(value, six.string_types):
          return os.path.expandvars(value)
      return value
docs: Call os.path.expandvars if value is a string, otherwise do nothing.