def _ensure_encodeable(value):
 try:
  json.dumps(value)
 except (ValueError, TypeError):
  return repr(value)
 return value

def _ensure_encodeable ( value ) : try : json . dumps ( value ) except ( ValueError , TypeError ) : return repr ( value ) return value
return a version of value that is guaranteed to be able to be logged .